RE: Reading a list of numbers into an array

2009-07-22 Thread Wagner, David --- Senior Programmer Analyst --- CFS
> -Original Message- > From: Emanuele Osimo [mailto:e.os...@gmail.com] > Sent: Wednesday, July 22, 2009 15:47 > To: beginners perl ml > Subject: Reading a list of numbers into an array > > Hello there, I'd like to read a file thet is a list of numbers like: > 3084 > 4855 > 2904 > making e

Re: Reading a list of numbers into an array

2009-07-22 Thread Chas. Owens
On Jul 22, 2009, at 19:07, "Shawn H. Corey" wrote: Chas. Owens wrote: #!/usr/bin/perl use strict; use warnings; my $fakefile = "6754\r\n7890\r\n6543\r\n"; open my $fh, "<", \$fakefile or die "could not open the fake file: $!"; open my $fh, '<:crlf', \$fakefile or die "could not op

Re: Reading a list of numbers into an array

2009-07-22 Thread Shawn H. Corey
Chas. Owens wrote: #!/usr/bin/perl use strict; use warnings; my $fakefile = "6754\r\n7890\r\n6543\r\n"; open my $fh, "<", \$fakefile or die "could not open the fake file: $!"; open my $fh, '<:crlf', \$fakefile or die "could not open the fake file: $!"; my @array; while (my

Re: Reading a list of numbers into an array

2009-07-22 Thread Chas. Owens
On Wed, Jul 22, 2009 at 18:04, Owen wrote: snip > It works for me. So try this snip Try this, it simulates what is probably happening: #!/usr/bin/perl use strict; use warnings; my $fakefile = "6754\r\n7890\r\n6543\r\n"; open my $fh, "<", \$fakefile or die "could not open the fake file:

Re: Reading a list of numbers into an array

2009-07-22 Thread Shawn H. Corey
Emanuele Osimo wrote: 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 (){ push (@array, $line) } but then printing the array just gives me the last number, in this case

Re: Reading a list of numbers into an array

2009-07-22 Thread Emanuele Osimo
Thanks a lot!! This is exactly what I needed! Emanuele On Wed, Jul 22, 2009 at 15:04, Wagner, David --- Senior Programmer Analyst --- CFS wrote: > > -Original Message- > > From: Emanuele Osimo [mailto:e.os...@gmail.com] > > Sent: Wednesday, July 22, 2009 15:47 > > To: beginners perl ml >

Re: Reading a list of numbers into an array

2009-07-22 Thread Owen
> 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 (){ push (@array, $line) } > but then printing the array just gives me the last number, in this > case > "2

Re: Reading a list of numbers into an array

2009-07-22 Thread Chas. Owens
On Wed, Jul 22, 2009 at 17:47, Emanuele Osimo wrote: > 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 (){ push (@array, $line) } > but then printing the array