Think about Loose Coupling | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Each use statement is executed at the moment it's been parsed. The same applies to a BEGIN block. my has two parts - the declaration of the variable happens immediately at compile time, the assignment happens later at run time. Therefore, in the first case, the dumping happens before the BEGIN block has been fully parsed, which means its (the BEGIN block's) code hasn't been run yet.
To make the variable lexical, specify before the BEGIN block. Update: You probably wanted something like
Update 2: Explanation of two parts of my.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
In reply to Re: Assignment and use statement in the same BEGIN block
by choroba
|
|