in reply to Could anyone explain the following Class::MethodMaker Code ?
Blech. That is really the sort of code that makes perl's bad reputation...
So what do we have ? here's my explanation : the enclosing "[]" force an anonymous array context. Inside we have 2 array elements :
"qw/name/" is just useless here because there's only one word...
Finally that's not very complex, just extremely obfuscated...
Here's what Data::Dumper can tell us about this structure, finally :
update : I forgot to mention that this structure looks like a pseudo-hash.
So what do we have ? here's my explanation : the enclosing "[]" force an anonymous array context. Inside we have 2 array elements :
The last one ( new => 'new') is clear enough. The first one is trickier : scalar is the hash key; let's analyse the content :scalar => [+{ -type => 'File::stat' }, qw/ name /], new => 'new',
the enclosing square braces once again force an anonymous array. Inside there are two elements :[+{ -type => 'File::stat' }, qw/ name /]
, the + force the following curly brace {} to be interpreted as an hash element and not a code block. so that's simply an anonymous hash entry.+{ -type => 'File::stat' }, qw/ name /
"qw/name/" is just useless here because there's only one word...
Finally that's not very complex, just extremely obfuscated...
Here's what Data::Dumper can tell us about this structure, finally :
It's way better, isn't it ?$VAR1 = { 'scalar' => [ { '-type' => 'File::stat' }, 'name' ], 'new' => 'new' };
update : I forgot to mention that this structure looks like a pseudo-hash.
|
---|
In Section
Seekers of Perl Wisdom