my ($value) = ($row =~ /.*,(.*)/); # gets value after the last comma if (looks_like_number($value)) { ($row =~ s/,[^,]*$//); # gets substring before the last comma # DO STUFF ... } # DO STUFF ...