What's That Prototype Again?

Ovid on 2008-08-22T12:42:38

Because of some weird mental block, I'm always forgetting the syntax of the prototype command. Thus, I now use this bash alias:

alias prototype="perl -le 'print prototype qq'"

And from the command line:

$ prototype bless
$;$

Hmm, bless has a prototype, eh? I should try to override it. I might just be able to create object instantiation graphs with this.


Why the +?

siracusa on 2008-08-22T13:54:15

What's the "+" before shift for?

Re:Why the +?

Ovid on 2008-08-22T14:40:39

Habit. It's not necessary. Thanks for pointing that out :)

Re:Why the +?

pstuifzand on 2008-08-22T14:46:04

The + has the same effect as scalar.

Devel::Leak::Object

AndyArmstrong on 2008-08-22T14:12:10

Devel::Leak::Object (highly recommended by the way) overrides bless - so it's certainly possible :)

Forget the shopping cart (usually)

Aristotle on 2008-08-23T12:03:26

One of my YAPC takeaways: ${\()} is usually preferable over @{[]}. One thing is that the dollar and parentheses are visually lighter than the at-sign and brackets, respectively – and much of the time the expression is just a function call, in which case you don’t even need the parentheses at all. Incidentally, creating a scalar ref and interpolating a scalar is a good deal cheaper than creating and interpolating an array, which matters in loops.

Unfortunately in this particular case it interacts with shell quoting, which makes it somewhat unpleasant compared to the shopping cart. The best I can pull off is this:

alias prototype="perl -le '"'print prototype qq<CORE::${\shift}>'\'

Not nice, but sufferable.