Syntactic Confectionery Delight | |
PerlMonks |
Re^3: help with error 'readline() on unopened filehandle'by 2teez (Vicar) |
on Feb 03, 2013 at 08:19 UTC ( [id://1016804]=note: print w/replies, xml ) | Need Help?? |
Hi bhargavkanakiya, $filename is the name of the file to open, and read from. In your code, "$filename" is not a FILEHANDLE. In Perl Programming, you need a file-handle in the open function like thus: open FILEHANDLE,MODE,EXPR Note: that you are not opening, your file named "$filename" to read from. You are just using it in the while loop with readline function as while ( my $line = <$filename> ) {...} which should really be while ( my $line = <FILEHANDLE> ) {...} So, your code should be something like: NOTE: All codes are not tested please.
If you tell me, I'll forget. If you show me, I'll remember. if you involve me, I'll understand. --- Author unknown to me
In Section
Seekers of Perl Wisdom
|
|