Beefy Boxes and Bandwidth Generously Provided by pair Networks
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

Replies are listed 'Best First'.
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
Re^6: help with error 'readline() on unopened filehandle'
by Anonymous Monk on Feb 03, 2013 at 08:36 UTC
      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

      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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1016803]
help
Chatterbox?
[Corion]: Eily: Sure - if you force both things into stringy things, then you break that magic. But that would also mean that you changed the expression, as now $x = 0.00 will be true instead of false as it were before
[Corion]: Ah no, at least in my feeble experiments that doesn't change the meaning
[Corion]: We sell sanity in small packages ;)
[Eily]: oh, boolean context uses the "" overload if no bool overload has been defined
[Eily]: (I wondered if overloading bool was actually necessary)

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (11)
As of 2017-07-27 13:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (414 votes). Check out past polls.