my ($dt, $timestamp, $refs); if ( m/^(.*) UTC.*refs = (\d+)$/ ){ # right here, just after the match, is the only # place it's safe to use $1 and $2 - tuck them away: my $t = $1; $refs = $2; $dt = $Strp->parse_datetime($t); $timestamp = $dt ->epoch(); } else { warn "No match: $_ \n"; next; } if ( defined($lookup{$refs}) && ....