Perl, using variable from within While loop outside of the loop?

You declare variable test inside the loop, so it scope is the loop, as soon as you leave the loop the variable is not longer declared Add my $test just between $i=1 and while(..) and it will work. The scope will now be the entire sub instead of only the loop.

You declare variable test inside the loop, so it scope is the loop, as soon as you leave the loop the variable is not longer declared. Add my $test; just between $i=1 and while(..) and it will work. The scope will now be the entire sub instead of only the loop.

2 ahh ok, I get it now.. thanks... the tutorials I've been looking at are too basic to even have mentioned this, I suppose I should go straight to the perl man pages from now on – Rick Jul 14 '10 at 9:15.

Place my $test before the while loop. Note that it will only contain the last value that is assigned in the while loop. Is that what you are after?

// will print "it's working" when 'the loop is hit at least once, // otherwise it'll print "it's not working" sub testthis { $i = 1; my $test = "it's not working"; while ($i.

You can try this one: sub testthis { my $test $i = 1; while ($i.

1 for mentioning use strict. – Abel Jul 14 '10 at 9:46.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions