The first thing that leaps at /me is the inappropriate escaping of the sigil in the regex. The next is that you ask would-be helpers to take at face value -- that is, without code to back up the claim -- that "(you) created a hash...." ... which, for the limited purpose of this WAG, I'll take for fact, since it's a plausible sample of a hash.

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. :-)

++$anecdote ne $data



In reply to Re: regex match multiple line by ww
in thread regex match multiple line (updated question) by natxo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.