in reply to regex match multiple line (updated question)

I'm not sure why you are approaching the problem this way. Am I missing something, or can't you just grab the error code from the error string, then do a lookup in your hash? For example:

$error = "00000056: AtrErr: DSID-03190F80, #1: 0: 00000056: DSID-03190F80, problem 1005 (CONSTRAINT_ATT_TYPE), da +ta 0, Att 9005a (unicodePwd) "; my %pwd_reset_errors = ( '0000052D' => "new password does not meet complexity requirements" +, '00000056' => "wrong old password", ); my($error_code) = ($error =~ m/(\d+):/); print $pwd_reset_errors{$error_code}, "\n";

This prints

wrong old password