in reply to Read from file to two arrays.

#!perl use strict; use warnings; my (@array1, @array2); while(<DATA>){ chomp; # with one regex: my ( $val1, $val2 ) = m/\A # beginning of line (\d+) # some numbers (capture) \+ # the plus sign \d+ # more numbers (don't capture) \, # the comma (escaped) ([0-9\.]+) # the second number \z # end of line /smx; push @array1, $val1; push @array2, $val2; # or you could:: # my @numbers = split /,/; # my @parts = split /\+/, $numbers[0]; # push @array1, $parts[0]; # push @array2, $numbers[1]; } print "$_\n" for @array1; print "$_\n" for @array2; __DATA__ 249+69,775.83 249+67,775.93 249+65,776.11

Does that do the trick? I'm a little unsure about what you mean when you refer to the the first value without the "+" sign. This solution just gives you the number before the + sign.

perl -e 'split//,q{john hurl, pest caretaker}and(map{print @_[$_]}(joi +n(q{},map{sprintf(qq{%010u},$_)}(2**2*307*4993,5*101*641*5261,7*59*79 +*36997,13*17*71*45131,3**2*67*89*167*181))=~/\d{2}/g));'

Replies are listed 'Best First'.
Re^2: Read from file to two arrays.
by Anno (Deacon) on Apr 15, 2007 at 09:08 UTC
    my ( $val1, $val2 ) = m/\A # beginning of line (\d+) # some numbers (capture) \+ # the plus sign \d+ # more numbers (don't capture) \, # the comma (escaped) ([0-9\.]+) # the second number \z # end of line /smx;
    Why escape the comma? It isn't special in a regex.

    Anno