in reply to Unusual variable declaration
The first line declares an alias $var for the global variable $var in the current package. The second line makes it an alias of the $var variable in the main package.
Therefore, it only makes sense to use this in a package different to main. For example:
#!/usr/bin/perl use warnings; use strict; our $var; $var = 42; { package My; our $var; *var = \$main::var; print $var, "\n"; $var = 84; } print $var, "\n";
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Unusual variable declaration
by LanX (Saint) on Nov 03, 2019 at 12:12 UTC | |
Re^2: Unusual variable declaration
by haukex (Archbishop) on Nov 02, 2019 at 21:49 UTC |
In Section
Seekers of Perl Wisdom