in reply to Re: @ARGV while (<>) hangs
in thread @ARGV while (<>) hangs

The file is also intentionally executed w/o an $in_file that is to say one is not submitted. It never hangs in those instances because if(defined $in_file) keep @ARGV and the while(<>) from coming into the mix.

Replies are listed 'Best First'.
Re^3: @ARGV while (<>) hangs
by ikegami (Patriarch) on Jan 08, 2008 at 23:11 UTC

    That's not true. "-" is defined, yet will cause <> to read from STDIN. So would "cat |".

    Along that same line, note that "rm -rf / |" would have "interesting" results. Why are you using <> (and thus the 2-arg open) instead of the safer 3-arg open?

      I see what your saying. I'll check to make sure that nothing except a legitimate filename is being passed as $in_file. However, may I ask what you mean by "<> (and thus the 2-arg open) instead of the safer 3-arg open"?
        <> uses the 2-arg open, which combines the "mode" with the file name. It allows pipes to be specified and thus the script can be used to execute arbitrary commands. That may makes sense for some command line tools, but not in general. When using the 3-arg open, the mode and the file name are kept seperate, so an arbitrary command cannot be sneaked in. Seperation of code and data is always safer.