use strict; use warnings; my $t; #comment out one of the next two lines #$a="1b2cde5";for($a=~/(\d+)/g){display($_, $1); $t+=$1;};print "$t\n"; $a="1b2cde5";for($a=~/(\d+)/g){display($_, $1); $t+=$_;};print "$t\n"; sub display { print "_ = " . shift() . ", 1 = " . shift() . "\n"; }