in reply to Print multiple lines based on condition

This code is a variation of the state-machine concept. The variable '$out' is a reference to the file handle of the current output file. When a 'command' line is discovered, the last hex digit of the address field is extracted. The "state" is set to one reference or the other depending on whether or not it is an even digit.
my $out; while (<INFILE>) { if(/addr:0x[0-9a-f]+([0-9a-f])/) { $out = ($1 =~ /[02468ace]/)? $OUT_FILE0 : $OUT_FILE1; } print {$out} $_; }
Bill