what does your code do? Let's see.
while (<'FILE'>)
{ $gline = <'FILE'>;
print $gline;
}
Line 1. while(<'FILE'>)
The <> operator takes a chunk of input from a filehandle, and assigns it to a variable. In this case, to $_, our favorite line noise default variable. So you have said, 'While you can pull a hunk of data out of FILE and stick it into $_, do some stuff.'
Line 2. { $gline = <'FILE'>;
Again with <>. This time you're explicitly assigning to $gfile. To translate into english, 'Put the next hunk of data you get from FILE into $gline.'
Line 3. print $gline;
Simply print the contents of $gline, which in this case is the even lines of your file.
Try this code ;)
while (<FILE>)
{ $gline = <FILE>;
push @even, $gline;
}
seek FILE, 0,0;
do
{ $gline = <FILE>;
push @odd, $gline;
} while (<FILE>);
foreach(0..$#odd)
{ print $odd[$_], $even[$_];
}
TGI says moo
|