girish_01 has asked for the wisdom of the Perl Monks concerning the following question:
hi all
i am very new to perl so please forgive my stupidity
i have written the following program to verify some parameters of an interface of router .I have saved the file in same directory as the perl program(perl1.pl). when i do perl1.pl filename.txt i get the error that
Use of uninitialized value $second_file in open at C:\Users\Girish\Desktop\perl1 .pl line 10. No such file or directory at C:\Users\Girish\Desktop\perl1.pl line 10.
The program is:
use warnings; $second_file=$ARGV[0]; $counter=0; open FH_SECOND,">",$second_file or die $!; $line_second=<FH_SECOND>;
i solved the problem by using
open (FH_SECOND,"<",\$second_file) or die $!;
but can i use the declaration $line_second=<FH_SECOND>; to save the a line in the variable line_second
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File Handling problem
by charlesboyo (Beadle) on Aug 28, 2011 at 17:38 UTC | |
by girish_01 (Initiate) on Aug 28, 2011 at 17:47 UTC | |
by poj (Abbot) on Aug 28, 2011 at 19:42 UTC | |
by girish_01 (Initiate) on Mar 19, 2012 at 17:56 UTC | |
|
Re: File Handling problem
by toolic (Bishop) on Aug 28, 2011 at 18:30 UTC | |
|
Re: File Handling problem
by ww (Archbishop) on Aug 28, 2011 at 19:33 UTC |