Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
We don't bite newbies here... much
 
PerlMonks  

Re^5: help with error 'readline() on unopened filehandle'

by Anonymous Monk
on Feb 03, 2013 at 08:19 UTC ( #1016803=note: print w/ replies, xml ) Need Help??


in reply to Re^4: help with error 'readline() on unopened filehandle'
in thread help with error 'readline() on unopened filehandle'

Don't put a '$' on your file handle. Here's how you open and read from a file:

$ cat file.txt line one line two line three $ cat open_and_read.pl #!/usr/bin/perl -w use strict; # usually one does not put a $ on a filehandle variable open ( MYFILE, "<file.txt" ) or die "could not be opening the file now + :$!\n"; while ( my $line = <MYFILE> ) { print $line; } close ( MYFILE ); $ ./open_and_read.pl line one line two line three


Comment on Re^5: help with error 'readline() on unopened filehandle'
Download Code
Re^6: help with error 'readline() on unopened filehandle'
by Anonymous Monk on Feb 03, 2013 at 08:36 UTC
      Well EXCUSE ME!!!!!! Back in my day sonny we didn't put '$' on our filehandle variables and LIKE IT! If you are going in for new fangled paradigms you might as well code in ruby >:(
        You are not excused. If you're going to correct folks, be sure to know what you're talking about first
      that's my advice for you ... read a ruby tut. get a hair cut and a JOB!

        that's my advice for you ... read a ruby tut. get a hair cut and a JOB!

        die

Re^6: help with error 'readline() on unopened filehandle'
by Anonymous Monk on Feb 03, 2013 at 08:37 UTC
    Also, 3 argument open is safer than 2 argument open -- sure you hardcoded the filename, but the OP hasn't

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1016803]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2014-04-20 19:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (486 votes), past polls