in reply to Re^6: Moo and Spreadsheet::ParseExcel
in thread Moo and Spreadsheet::ParseExcel
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^8: Moo and Spreadsheet::ParseExcel (explain?)
by tye (Sage) on Nov 17, 2012 at 19:29 UTC | |
by tobyink (Canon) on Nov 17, 2012 at 23:45 UTC | |
by tye (Sage) on Nov 18, 2012 at 01:16 UTC |