in reply to String replace with function
#!/usr/bin/perl -l # http://perlmonks.org/?node_id=1172179 use strict; use warnings; sub add { 4 * shift; } $_ = '123 - 4 - 75 - 12'; print; s/(\d+)/ add($1) /ge; print; [download]