while(chomp($input = )) { if ($input =~ m/^(\+\ \ \()([1234]\.[0-9])(.*)/) { print "$1_$2_$3\n"; } else { print "$input\n"; } }