borisz has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I just want to alias a scalar to a different package var. But only the * notation work as expected. This looks like a bug to me, but propably someone can explain the behavior.
I expect, that both aliases do the same and the output is 'boris boris'
I just want to alias a scalar to a different package var. But only the * notation work as expected. This looks like a bug to me, but propably someone can explain the behavior.
I expect, that both aliases do the same and the output is 'boris boris'
package XYZ; sub test { local *name = \'boris'; $_[1]->() } package ABC; *scalar_alias = \$XYZ::name; # does not work *glob_alias = *XYZ::name; # DWIM package main; use warnings; XYZ->test( sub { print 'scalar_alias: ', $XYZ::name, ' ', $ABC::scalar_alias, $/; print 'glob_alias: ', $XYZ::name, ' ', $ABC::glob_alias, $/; } ); __OUTPUT__ scalar_alias: boris glob_alias: boris boris Use of uninitialized value in print at untitled 74.pl line 15.
Boris
Back to
Seekers of Perl Wisdom