in reply to regex match multiple line (updated question)
But the next big ugly is is that you haven't given us enough with which to confidently jump off a cliff.
... but here goes anyway (sure hope the water's deep down there) (code and output updated for clarity):
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 esca +pe 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" +; } }
Execution:
C:\>1108508.pl Didn't find a match for 123xx51y [ Not a Windows error (or undocumente +d) ]) 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
Note the use of qr in the declaration of the string you're trying to use (I think -- sorry, Xtal ball is gebroke!) as a regex... and, of course, the use of strict, warnings, etc.
...and that the irony in the messages IS intentional. :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regex match multiple line
by natxo (Scribe) on Nov 26, 2014 at 22:48 UTC | |
by graff (Chancellor) on Nov 27, 2014 at 01:22 UTC | |
by natxo (Scribe) on Nov 27, 2014 at 07:52 UTC | |
by james28909 (Deacon) on Nov 27, 2014 at 01:48 UTC |