Perl-Sensitive Sunglasses | |
PerlMonks |
Re^9: Moo and Spreadsheet::ParseExcel (explain?)by tobyink (Canon) |
on Nov 17, 2012 at 23:45 UTC ( [id://1004359]=note: print w/replies, xml ) | Need Help?? |
Moo::Role loops through the list of roles with a for loop, using the default loop variable, global $_. (Or rather it did, as this is now fixed.) In for loops, the loop variable is an alias into the array. If you assign to it, the original array is altered. Thus within that loop, if $_ were assigned to, it would alter the list of roles. Now, what happens within the loop? The role modules get required. And thus any modules that the role modules use get loaded too. And in all that code that gets loaded, somewhere, undef gets assigned to global $_. (And no, I don't know exactly where... Spreadsheet::WriteExcel has a number of dependencies.) That's how undef gets into @roles.
Role::Tiny has:
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
In Section
Seekers of Perl Wisdom
|
|