Surprising Deparse Result

Ovid on 2009-04-03T12:14:25

Tracked down a weird bug in our code. This could make for interesting obfuscations.

$ perl -MO=Deparse -e 'f("x");sub f {expand { datatype => shift }}'
f('x');
sub f {
    do {
        'datatype', shift @_
    }->expand;
}
-e syntax OK


WTF Is expand?

Theory on 2009-04-04T02:21:36

WTF is expand?

% perldoc -f expand
No documentation for perl function `expand' found

--Theory

Re:WTF Is expand?

Ovid on 2009-04-04T09:19:35

The weird code just through you off there. It's a key in a hash. If there was a fat comma (=>) to the right of "expand", that code would look and behave just fine.

Re:WTF Is expand?

Theory on 2009-04-04T16:11:50

Ah, I see. Except that it's not a key in a hash in that code, but a method.

--Theory

Re:WTF Is expand?

Ovid on 2009-04-05T10:27:17

A: I should have written "threw", not "through". I hate it when I do that. B: I know it's a method. That was the point of the original post :)

Indirect object syntax

castaway on 2009-04-05T08:56:39

Not all that surprised, I assume that works the same way as:

my $dog = new Dog;

does. More not-much-used-syntax we should get rid of?

(Hmm, print uses it, took me a while to figure which doc it's in, perlobj)

Aren't typos fun?