Ken Williams writes:
> Huh?  3-arg open?  I haven't seen this in the various writeups of
> new 5.6.0 features, and the docs at
> http://www.perl.com/CPAN-local/doc/ are still stuck on 5.005_02.  My
> curiosity is piqued!

Here are the examples from the open entry in the perlfunc manpage.

  open(DBASE, '+<', 'dbase.mine')             # open for update
  open(ARTICLE, '-|', "caesar <$article")     # decrypt article

  # these 3 are roughly equivalent
  open(FOO, "|tr '[a-z]' '[A-Z]'");
  open(FOO, '|-', "tr '[a-z]' '[A-Z]'");
  open(FOO, '|-') || exec 'tr', '[a-z]', '[A-Z]';

  # these 3 are roughly equivalent
  open(FOO, "cat -n '$file'|");
  open(FOO, '-|', "cat -n '$file'");
  open(FOO, '-|') || exec 'cat', '-n', $file;

3-arg open() is sweet, but not as nifty as autovivifying handles.

Nat

Reply via email to