in reply to String substitution

Another way: each transformation gets its own substitution. This depends on discriminating between different types of  \d+ groups by their preceding patterns. Needs Perl version 5.10+ for the  \K regex operator; can be re-written to avoid using  \K (i.e., for pre-5.10) if needed.

c:\@Work\Perl\monks>perl -wMstrict -le "use 5.010; ;; my $str = 'hello nr34,nr56,78, 98 , hi, 76'; print qq{'$str'}; ;; $str =~ s{ (nr\d+) }{calc($1);}xmsg; $str =~ s{ , \s* \K (\d+) }{ $1 * 4 }xmsge; print qq{'$str'}; " 'hello nr34,nr56,78, 98 , hi, 76' 'hello calc(nr34);,calc(nr56);,312, 392 , hi, 304'


Give a man a fish:  <%-{-{-{-<