in reply to Re: What the @#%* lost again!
in thread problem opening and reading from a file

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

Replies are listed 'Best First'.
Re: Re: What the @#%* lost again!
by svsingh (Priest) on Jul 02, 2003 at 21:39 UTC
    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