On Jul 10, 5:24 pm, [EMAIL PROTECTED] (Mayank Ahuja) 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. > > regards > Mayank > =====-----=====-----===== > 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
>> my @lines = <FH>; >>while (<FH>) >>print $. ; >>} The file slurp on the first line reads entire file and puts each line in @lines. Next <FH> read in while() always returns undef, since the file is read entirely. Iterate over @lines instead - Gowtham -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/