[EMAIL PROTECTED] wrote:
Hi Perlers

Hello,

cud u plz tell me what wrong in this :

Could you please use proper English?

#!/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>;

This reads all the lines from the file. Any attempt to read from the FH filehandle after this will return EOF (undef).

while (<FH>)

You have a syntax error, you are missing {. The FH filehandle is at EOF so <FH> will return undef and the loop will not run.

print $. ;
}
close(FH);


But its neither printing line number  nor giving any error.

It should report the syntax error.  What you probably want is:

my @lines = <FH>;
print $.;




John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

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


Reply via email to