The Minus File
Again following the lead of the standard shell utilities, Perl’s open function treats a file whose name is a single minus, “-“, in a special way. If you open minus for reading, it really means to access the standard input. If you open minus for writing, it really means to access the standard output.

UPDATE
========
The minus file is not working with 3-argument open.

Bryan> How can I use the “safe” 3-argument open and still be able to read off a
Bryan> pipe?

You don’t. 2-arg open has to be good for something.

And 2-arg open is perfectly safe if the second arg is a literal:

open OTHER, “<-" or die; open my $handle, "<-" or die; Don't let anyone tell you "Always use 3-arg open" unless they also footnote it with "unless you have no variables involved". -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion

The Minus File Again following the lead of…
Tagged on:

Leave a Reply

Your email address will not be published. Required fields are marked *