Vladimir Lemberg wrote:
I have this file:
foobar-45whatever-37hello16goodbye9#!!!
snafu23skidoo---+++++30++++-50
I need to store all digits into list. As you can see there is no
any obvious delimiter, so I'm using global matching
open (INFILE, "$ARGV[0]") || die "cannot open $ARGV[0].\n";
@digits = <INFILE> =~ /-*?\d+/g;
print "@digits";
The problem is that @digits took only first line of my file.
You can enable "slurp mode":
local $/;
my @digits = <INFILE> =~ /-?\d+/g;
(as far as I understand, the * quantifier is redundant)
Or you can see to it that all the lines are processed:
my @digits;
push @digits, /-?\d+/g for <INFILE>;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>