while () { } #### my $re = qr/^$year-.{21} IP (?:\Q$IP1\E > \Q$IP2\E|\Q$IP2\E > \Q$IP1\E/; while () { next unless /$re/; ... do something ... }