[EMAIL PROTECTED] wrote:
Hi Perlers
cud u plz tell me what wrong in this :
#!/usr/bin/perl
use strict;
use warnings;
print "Enter the File name \n";
my $input_file = <STDIN> ;
chomp($input_file) ;
open FH,$input_file or die "Can not open the file at $!" ;
my @lines = <FH>;
while (<FH>)
print $. ;
}
close(FH);
But its neither printing line number nor giving any error.
The line:
my @lines = <FH>;
slurps in the entire file. Thusly the while statement will exit
immediately since there is nothing left in the file. Removing this line
will print the line numbers.
--- Shawn
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/