use strict; use warnings; my @data; while () { chomp; my ($first, $second) = split ','; next unless defined $second; $first =~ tr/+//d; push @data, [$first, $second]; } print join "\n", map {"$_->[0], $_->[1]"} @data; __DATA__ 249+69,775.83 249+67,775.93 249+65,776.11 #### 24969, 775.83 24967, 775.93 24965, 776.11