スキップしてメイン コンテンツに移動

投稿

12月, 2009の投稿を表示しています

Quid Pro Quo

One thing that I don't like about scripting languages is usage of bizarre identifiers. Statically compiled languages don't care about verbose identifiers, but scripting languages often employ abbreviated names to gain run-time performance and typing speed. my ( $x, $y ) = $self->invoke( +{ METHOD => 'foo', PARAM => 'bar', }, '' ); In this Perl snippet, I had no idea what "+{}" stands for. It looks like some kind of hash, but not sure. Googling it didn't bring good results since Google doesn't recognize a string made only of non-alphabetical characters such as braces and math operators. To figure out its meaning I wasted so much time by trying many different words in Google. Anyway here's the answer: or to force an anon hash constructor use +{ : @hashes = map +{ lc ($_) => 1 }, @array # EXPR, so needs comma at end to get a list of anonymous hashes each with only one entry apiece. It's embedde