Re: 3-argument open on STDIN



"Bryan" == Bryan R Harris <Bryan_R_Harris@xxxxxxxxxxxx> writes:

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
<merlyn@xxxxxxxxxxxxxx> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion
.



Relevant Pages

  • Re: 3-argument open on STDIN
    ... And 2-arg open is perfectly safe if the second arg is a literal: ... With this tool if there's a pipe and no user-supplied files, ...
    (perl.beginners)
  • Re: 3-argument open on STDIN
    ... Bryan> pipe? ... And 2-arg open is perfectly safe if the second arg is a literal: ... With this tool if there's a pipe and no user-supplied files, ...
    (perl.beginners)
  • Re: awk problem
    ... Len> I readfile or pipe this text, ... Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. ... See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion ...
    (freebsd-questions)
  • Re: pipe and read oddity
    ... Robert> In short: Why doesn't 'read' assign any values to variables h and m ... Gotta fork to do a pipe. ... Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. ...
    (comp.unix.shell)