> -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
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
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
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:
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
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
>
> 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
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