> Hello there, I'd like to read a file thet is a list of numbers like:
> 3084
> 4855
> 2904
> making each line (each number) one of the elements of the array. I've
> tried
> foreach my $line (<FILEHANDLE>){ push (@array, $line) }
> but then printing the array just gives me the last number, in this
> case
> "2904".
> What's wrong?
>
> Thanks
> Emanuele
>


It works for me. So try this
(Yes, I haven't used strict)
===================================================
#!/usr/bin/perl

foreach my $line (<DATA>){ push (@array, $line) }

print "@array\n";

__DATA__
6754
7890
6543

====================================================
-- 



Owen


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to