On 7/13/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote: snip
open (FILEIN, "< $ARGV[0]") or die $!; my @lines = <FILEIN>;
snip
In list context the <> operatot returns all lines, but in scalar context it returns on line at a time. This can be used with a while loop to walk over the file in pieces (a necessity for large files). Also, you do not need a copy of $line, just change the substitution to a match. #!/usr/bin/perl use strict; use warnings; unless (@ARGV == 2) { die qq(usage: ConvertASCII.pl "input file name" "output file name"\n) } open my $in, '<', $ARGV[0] or die "could not open $ARGV[0]: $!"; open my $out, '>', $ARGV[1] or die "could not open $ARGV[1]: $!"; while (defined (my $line = <$in>)) { my $line2 = $line; my ($x, $y, $z) = $line =~ /(\S+)\s+(\S+)\s+(\S+)/; print $out "X$x Y$y\nZ[$z+DPad]\nM98PDRILL.SUBL1\nG90\nG00 Z[CPlane]\n"; } or if you prefer for the print to be more readable: print $out "X$x Y$y\n", "Z[$z+DPad]\n", "M98PDRILL.SUBL1\n", "G90\n", "G00 Z[CPlane]\n"; Never use multiple print statements when you can use just one. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/