in reply to Re: # Translation
in thread # Translation
use strict; use warnings; use strict; while (<DATA>) { if (/^Curve(\d):/.../^\s*$/) { if (defined($1) && $1==1 && /^\d/) {print "C1: $_\n";}; if (defined($1) && $1==2 && /^\d/) {print "C2: $_\n"}; } } __DATA__ Curve1: 123, 456 end 123 Curve2: 789, 101 end 123
Prints:
C1: 123, 456 C2: 789, 101
Using $1 etc after a failed match is generally an error, but not in this case. The fact that $1 is not reset is relied on by the code.
|
|---|