> Because the push() statement is in a loop, and my() would empty
> the variable at each iteration.
> 
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl

Hi Gunnar ... Thanks for the help.

I assure the list, the following is the code EXACTLY as I was using it to test:
#!/usr/bin/perl

use warnings;
use strict;

my @numbers;
push @numbers, split while <>;
foreach (sort { $a <=> $b } @numbers) {
  printf "%20g\n", $_;
}

This works flawlessly, with no warnings or error messages.

I tried to modify the script, as seen below:

#!/usr/bin/perl

use warnings;
use strict;

push my @numbers, split while <>;
foreach (sort { $a <=> $b } @numbers) {
  printf "%20g\n", $_;
}

This code produces no output ... not even any warnings or errors.

Gunnar, I believe your explanation makes the most sense to me.  With
the my operator (function?) reseting the value of the @numbers
variable each time the loop is run, the output would not be in error,
it would just be empty.

So, now my question becomes, is there a way to watch this variable,
before, throughout and after the loop to confirm that it is being
reset each time.  More specifically, my problem now is, if the
variable is being reset throughout the loop, shouldn't the final
iteration of the loop have produced SOME output, albeit only the last
bits?  Maybe it has something to do with the precedence of the actual
line of code in the loop.  the:

  push my @numbers, split;

--Errin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to