Your syntax is wrong. Each time you say <FILE> you get another line - you do this twice for each while loop but only assign and print one line. Thus you skip every second line. You don't need the ' quotes either. Here is a script that does it two different ways. $. is the current line in the file. $_ is a magical Perl var that contains the line in the first chunk of example code. First you see the code, then its output.
C:\>type test.pl
print "\nRead files off command line\n";
while(<>) {
print "$. $_";
}
print "\n\nRead file in usual way\n";
$file = 'c:/test.pl';
open F, "<$file" or die "Oops Perl says $!";
while (my $line = <F>) {
print "$. $line";
}
close F;
print "\n\n\nPerl Rocks!\n";
C:\>perl test.pl test.pl
Read files off command line
1 print "\nRead files off command line\n";
2 while(<>) {
3 print "$. $_";
4 }
5
6 print "\n\nRead file in usual way\n";
7 $file = 'c:/test.pl';
8 open F, "<$file" or die "Oops Perl says $!";
9 while (my $line = <F>) {
10 print "$. $line";
11 }
12 close F;
13
14 print "\n\n\nPerl Rocks!\n";
Read file in usual way
1 print "\nRead files off command line\n";
2 while(<>) {
3 print "$. $_";
4 }
5
6 print "\n\nRead file in usual way\n";
7 $file = 'c:/test.pl';
8 open F, "<$file" or die "Oops Perl says $!";
9 while (my $line = <F>) {
10 print "$. $line";
11 }
12 close F;
13
14 print "\n\n\nPerl Rocks!\n";
Perl Rocks!
C:\>
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|