holli has asked for the wisdom of the Perl Monks concerning the following question:

In various nodes i saw some fellow monks saying that the three-argument-form of open is safer than itīs two-argument form. Rereading perlfunc I cannot find anything that backs this.

Anyone can shed some light on this?


holli, /regexed monk/

Replies are listed 'Best First'.
Re: open()'s 3 argument form
by TedYoung (Deacon) on Feb 18, 2005 at 21:29 UTC

    It keeps you from having to worry if your filename begins or ends with one of the special redirection markers. For example:

    $filename = "afunnynameendingwitha|"; open F, $filename; # Bad, will try to fork a proc. open F, '<', $filename; # Good, opens the funny file.

    Other note: Check out perlopentut.

    Ted Young

    ($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)