# code 1 $str = "abc"; for (1, 2, 3) { print $1 if $str =~ ?(.)?g; } # code 2 $str = "abc"; print $1 if $str =~ ?(.)?g; print $1 if $str =~ ?(.)?g; print $1 if $str =~ ?(.)?g; #### $str = "abc"; for (1, 2, 3) { $str =~ ?(.)?g; print $1; } #### $str = "abc"; { local ($_1, $_2, ...); for (1, 2, 3) { $str =~ ?(.)?g and ($_1, $_2, ...) = ($1, $2, ...); print $_1; } }
## $str = "abc"; for (1, 2, 3) { $str =~ ?(.)?g; print $1; } ##
## $str = "abc"; { local ($_1, $_2, ...); for (1, 2, 3) { $str =~ ?(.)?g and ($_1, $_2, ...) = ($1, $2, ...); print $_1; } }