#!perl use strict; use warnings; my (@array1, @array2); while(){ 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 #### perl -e 'split//,q{john hurl, pest caretaker}and(map{print @_[$_]}(join(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));'