Re: open()



Klaus Jantzen wrote:
In a reply by A. Guzman I found the following paragraph:
==

Please be careful with your open(), you will have problems if you do not
use a multiple argument open(), ....
And you shouldn't use bare-word filehandles.

==
So far I used quite successfully bare-word filehandles except in the
cases where
I wanted to pass the filehandle to a subroutine or store it somewhere.
Why should one separate the ">" etc. from the file name?


print "Enter a file: \n";
chomp (my $filename = <STDIN>);
open FILE, $filename or die "Cannot open file: $!";
while (<FILE>) {
print;
}


Change to a temporary directory. Create a couple files in it. Run the
above program, and enter this at the prompt:
| rm *

And then see what happens to your temp directory.

Paul Lalli

.