Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: What the @#%* lost again!

by svsingh (Priest)
on Jul 02, 2003 at 21:02 UTC ( #270954=note: print w/replies, xml ) Need Help??


in reply to problem opening and reading from a file

This is just a guess, but I think read is a reserved word. Does the script work if you change READ to soemthing else, like READDATA?

Update: Added code markers.

Replies are listed 'Best First'.
Re: What the @#%* lost again!
by Abigail-II (Bishop) on Jul 02, 2003 at 21:17 UTC
    READ isn't a reserved word in Perl, but read is. But it's fine to use filehandles with the same name as (some) all-caps words with a special meaning, as shown below:
    #!/usr/bin/perl use strict; use warnings; open BEGIN, "/etc/passwd" or die; print while <BEGIN>; __END__

    The program compiles and runs without problems.

    Abigail

      Thanks for letting me know that Abigail. I didn't realize you could use reserved words in filehandles. I guess it's just more of a recommendation that you don't use them. Thanks again.
        Well, I carefully worded it "all-caps words with a special meaning". BEGIN isn't a reserved word. However, you can use reserved words as file handles, as long as you quote them when appropriate:
        #!/usr/bin/perl use strict; use warnings; open print => "/etc/passwd" or die; print while <print>; __END__

        If you replace the => with a comma, the code above won't compile.

        Abigail

Re: Re: What the @#%* lost again!
by Anonymous Monk on Jul 02, 2003 at 21:07 UTC
    sure doesnt .. :( i dont get it? There is no crying in perl or I would!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://270954]
help
Chatterbox?
[marto]: it's a shame Solaris is such a PITA to build on :)
LanX great movie!
[Discipulus]: ah i become monsignor the same day of sysadmin day
[marto]: not so great OS :P
Eily never heard of the movie "LanX"
[Eily]: the LanX OS either now that I think of it :P
[hippo]: Congratulations, Discipulus!
[Discipulus]: Satura Lanx was a latin genre of show
[Discipulus]: coming from the meaning of 'mixed dish'

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2017-07-28 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (426 votes). Check out past polls.