use strict; use warnings; use 5.018; # 1108508 my $error = qr/00000056|0000052D|05601111/; my %pwd_reset_errors = ( '0000052D' => "new password does not meet complexity requirements", '00000056' => "wrong old password", '05601111' => "Friends don't let friends use Doze", '123xx51y' => "Not a Windows error (or undocumented)", ); while ( my ( $key, $value ) = each %pwd_reset_errors ) { if ( $key =~ m/^$error.*/ ) { # Don't escape the sigil here! say "matched \$key: $key in \$error: \r\n\t \$value: $value\n"; } else { say "Didn't find a match for $key [ $value ]) in regex $error\n"; } } #### C:\>1108508.pl Didn't find a match for 123xx51y [ Not a Windows error (or undocumented) ]) in regex (?^u:00000056|0000052D|05601111) matched $key: 00000056 in $error: $value: wrong old password matched $key: 0000052D in $error: $value: new password does not meet complexity requirements matched $key: 05601111 in $error: $value: Friends don't let friends use Doze