http://www.perlmonks.org?node_id=554784

jesuashok has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks,

When I executed the below code, I found that the variable which is being used in a separate block with the scope 'local' is not being able to use outside the block.

Please check how the '$x' is being used in the below code.

#!/usr/bin/perl -w $x = "123 56"; $x =~ / /g; print "$x, ", pos($x), "\n"; { local $x } print "$x, ", pos($x), "\n";
Output :-
123 56, 4 Use of uninitialized value in print at l.pl line 5. 123 56,
what does the 'pos' do with '$x' ?

"Keep pouring your ideas"

2006-10-08 Unapproved by planetscape once evidence of habitual plagiarism uncovered.