Dear ALL,
I was debug some old dirty script of mine (which without strict nor warnings ^_^), and faced this issue:
As you can see in case(1), variable $me had been declared more than once, and to output of this script is: []
#----------[ CASE(1) ]----------# my $v_place = 'home'; my $me = 'moving'; my $me = 'at home' if($v_place =~ m/^home/); my $me = 'at work' if($v_place =~ m/^work/); print "[$me]"; __END__ output: [] #-------------------------------#
But after correct the declaration problem as in case(2), we got the correct output: [at home].
#----------[ CASE(2) ]----------# my $v_place = 'home'; my $me = 'moving'; $me = 'at home' if($v_place =~ m/^home/); $me = 'at work' if($v_place =~ m/^work/); print "[$me]"; __END__ output: [at home] #-------------------------------#
Now,can any monk explain me just what happen here?
BR
Hosen
In reply to "my" declaration problem by Hosen1989
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |