use strict; use warnings; use diagnostics; my( $first, $second ) = ( "a1b2c3d4e5f6", "AaBbCc" ); while( $first =~ m/(\d)/g ) { print "\$first matched on $1\n"; while( $second =~ m/([a-z])/g ) { print "\t\$second matched on $1\n"; } }