in reply to # Translation

What is the meaning of the following code?
Beats me. I don't think the if()s surrounding the prints is ever true (but I haven't tried it), so my guess is that the code generates two empty files.
Would you place # comments at the end of each line.
No.

Replies are listed 'Best First'.
Re^2: # Translation
by GrandFather (Saint) on Apr 09, 2009 at 21:11 UTC
    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.


    True laziness is hard work