At
340460, I was replying and used the construct
$self->{_$_}. I didn't quote it because hashkeys autoquote. Yet.
Fletch correctly pointed out that
$self->{_$_} deparses to
$self->{$_->_}. Not only that, but it actually executes!
perl -e '$self->{a$_};print keys %$self, $/;'
--------
Can't call method "a" on an undefined value at -e line 1.
Going further, I get the following:
package Foo;
sub new { my $c = shift; bless \$c, $c }
sub bar { 'bar' }
package main;
$foo = Foo->new;
$x{bar$foo} = 1;
print "$_ => $x{$_}\n" for keys %x;
--------
bar => 1
Further testing shows that $x{bar $foo} and $x{$foo->bar} also work.
Now, I knew that $x{bar()} works, because that's how you get constants in there. But, method calls?
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.