while () { my $line = $_; my @file; push @file, $_; # the numbers are floating point if ($line =~ /^(\d+\s+)(\d+\W?\s+)(\d+\W?\s+)/) { push @nums, $2 if $2 =~ /\d+/; push @nums2, $3 if $3 =~ /\d+/; } } my ($i, $j); print "$i\t $j\n";