in reply to Problem with regexp or saved match variable.

The variables $1, $2 and $3 keep their old values when the match fails so when the second element doesn't match the values from the first match are used.

You need to verify that the match succeeded before using the numerical variables.   Something like:

my @array = ( '<Band:3>40M <Call:5>KD4RR <QSL_Rcvd:1>Y <QSL_Sent:1>Y', '<Band:3>40M <Call:5>K7RRR <QSL_Sent:1>Y', '<Band:3>40M <Call:5>W7FAL <QSL_Rcvd:1>Y <QSL_Sent:1>Y', ); for ( @array ) { if ( /QSL_R(?:CVD|cvd):\d+>(\w+)/ && $1 eq 'Y' ) { print "Good Record: $_\n"; } else { print "Bad Record: $_\n"; } }