Hi Paul

I don't think so.In my mail I was so much rude  , but if you still feel so 
then I want to apologize.



regards

Mayank 



Paul Lalli <[EMAIL PROTECTED]> 
07/10/2007 11:14 PM

To
beginners@perl.org
cc

Subject
Re: regd . Line number printing...






On Jul 10, 8:24 am, [EMAIL PROTECTED] (Mayank Ahuja) wrote:
> cud u plz tell me what wrong in this :

Could you please talk like an adult?  Not only do you give the
impression that you're 10 years old, you are rude to non-native
speakers of the English language who could possibly help you.

> #!/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 line slurps the entire file into the array @lines.  There is
nothing left to be read from the FH filehandle once this line is done.

> while (<FH>)

Syntax error.  Missing opening brace.  Please do not re-type your
code.

As I said, there is nothing left to read from the FH filehandle. You
read it all already, into the array @lines.  If you want to start
reading again, you have to seek() (see `perldoc -f seek`).  Otherwise,
this loop will never execute because <FH> returns undefined after FH
has had all its data read.

> print $. ;}
>
> close(FH);
>
> But its neither printing line number  nor giving any error.

Because there is no syntax nor runtime error there.  Perl is doing
exactly what you asked it to do.

Paul Lalli


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


ForwardSourceID:NT0000B75A 
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you


Reply via email to