... while () { if ( /^Equipment:.*?(\d+)-(\S+)/ ) { ( $str1, $str2 ) = ( $1, $2 ); } elsif ( /^solved:\s+(\S+)\s+"([^"]+)/ ) { ( $str3, $str4 ) = ( $1, $2 ); print "Found: str1= $str1 str2= $str2 str3= $str3 str4= $str4\n"; } }