Joseph L. Casale wrote:
One of these scripts has a loop like this:

for my $line (@lines){
 my $line2 = $line;
 $line =~ s/(\S+)\s+(\S+)\s+(\S+)/X$1 Y$2/;
 print FILEOUT $line;
 $line2 =~ s/(\S+)\s+(\S+)\s+(\S+)/Z[$3+DPad]/;
 print FILEOUT $line2;
 print FILEOUT "M98PDRILL.SUBL1\n";
 print FILEOUT "G90\n";
 print FILEOUT "G00 Z[CPlane]\n"
}

What would be a wise way of trapping a condition such as the line read
and passed into the loop is not 3 sets of numbers and if so, skip?

It's also worth pointing out that Paul originally loaded the file data
into an array so that he could use it twice in two successive loops.
Unless the amount of your data is tiny it's much better to remove the
array @lines and write this loop as

while (<DATA>) {
 :
}

which reads the file one line at a time and doesn't need to draw it all
into memory at once.

Cheers,

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to