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".


Hmm. With this tool if there's a pipe and no user-supplied files, I just
put "-" onto the list of files to search -- using the 2-arg open. Someone
suggested that was a bad idea, so I switched to the 3-arg open but that
broke reading off the pipe.

So is it right that in order to read off the pipe *and* be safe, I have to
have both types of "open" statements in my code?

- Bryan


.



Relevant Pages

  • Re: 3-argument open on STDIN
    ... On 23/08/2011 04:17, Bryan R Harris wrote: ... 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: ... Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. ...
    (perl.beginners)
  • 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: two way piped open
    ... Bryan R Harris wrote: ... > I'd like to open 2-way pipe to a tool that we have here. ... > yprtool and once it's open, you give it 3 numbers to its STDIN and it spits ...
    (perl.beginners)