Don't ask to ask, just ask | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
my $_ should work, but local $_ would fail. It's because the loop variable in a for loop is an alias to each element of the array. So the global $_ is an alias into @roles in this case. Assigning to global $_ assigns into the @roles array. local (despite the name) operates on global variables, providing a local value for them, but not really creating a new local variable. So even in the scope of local $_ assigning to $_ will assign into @roles. It's a particular combination of Perl features which is normally fairly safe to use, but because apply_roles_to_package also happens to load modules (and thus run third-party code - i.e. code which is not part of Moo) it causes problems.
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
In reply to Re^7: Moo and Spreadsheet::ParseExcel
by tobyink
|
|