Unmatched ) in regex; marked by <-- HERE in m/ [A-Z]+ # WB \(\d+,\d+) <-- HERE # (1,2) \s*=\s* # = (?: # start non-capturing group \d+\.\d+, # a float followed by comma \s*(\d+\.\d+),? # capture a float (followed by comma?) ) # end-group / at /tmp/wb line 10. #### $_ = 'WB(1,2)= 0.000, 1.23, TB(1,2)= 0.0, 253.0, TMB(1,2)= 0.0, 1.0, SL(1,2)= 0.00, 1.00'; my @parts = split /, /; $parts[1] = 3.21; # change 1.23 with 3.21 $_ = join ', ', @parts; print $_, "\n"; # output: # WB(1,2)= 0.000, 3.21, TB(1,2)= 0.0, 253.0, TMB(1,2)= 0.0, 1.0, SL(1,2)= 0.00, 1.00