in reply to Re: regex match multiple line
in thread regex match multiple line (updated question)

Thanks! I get the irony ;-)

In fact the $error is not the regex I want to match, but the other way round. I want to match the key of my hash as a regex to the error I get from Net::LDAP.

I apologize for the confusion.

Replies are listed 'Best First'.
Re^3: regex match multiple line
by graff (Chancellor) on Nov 27, 2014 at 01:22 UTC
    In case you haven't figured it out yet, you're really close. In your while loop, change this:
    if ( $key =~ m/^$error.*/ ) {
    to this:
    if ( $error =~ m/^$key:/ ) {
    Then again, maybe I totally misunderstood your question.
      yes, that was the mistake :(

      Thanks!

Re^3: regex match multiple line
by james28909 (Deacon) on Nov 27, 2014 at 01:48 UTC
    while ( my ( $key, $value ) = each %pwd_reset_errors ) { if ( $key =~ m/^$error.*/ ) { ... }
    This iterates thru the hash list %pwd_reset_errors right? So whats wrong with doing it like this above IF the key matches the error code? Why would you want to match it the other way around? I am just asking for better understanding :)

    To me its like you wanting to do soemthing of this nature:
    my $one = 1; if ($one =~ 1){ ... }elsif(1 =~ $one){ ... }
    Why would it matter if $one eq 1 or 1 eq $one, they were both the same thing. But like i said i am just asking for better understanding.


    EDIT: I just realized that Net::LDAP error is quite different than your keys in the hash. You could split the error code from Net::LDAP so it just contains everything before ':' and then match either way.

    EDIT 2: I had to much coffee. ;l