in reply to sort routines crossing package lines
The first one copies only the scalar value slot of the glob, the latter copies all slots. Therefore, I suspect the reason that the glob export works and the other doesn't is that $a and $b don't reside in the normal scalar slots. Update: (Or maybe their "magic" flags don't get copied without the glob. There's a section in perlsub about "localization of globs" that says you can make variables lose their magic by localizing their glob).# Regular $a, $b export: *{main::a} = ${Sorts::a}; *{main::b} = ${Sorts::b}; # Glob *a, *b exports: *{main::a} = *{Sorts::a}; *{main::b} = *{Sorts::b};
The perlvar page indicates $a and $b are special, "Because of this specialness $a and $b don't need to be declared (using local(), use vars, or our()) even when using the strict vars pragma."
Update 2: I believe [id://ysth] has the right answer.
|
|---|