in reply to Re: Automatic generation of textfiles
in thread Automatic generation of textfiles

While it's possible in shells to use exec to reopen descriptors, Perl's exec is a different beast. You'll either replace your running program with a very short lived shell, or you'll spawn a child shell which won't affect the parent process' file descriptors in any way.

  • Comment on Re^2: Automatic generation of textfiles

Replies are listed 'Best First'.
Re^3: Automatic generation of textfiles
by idle (Friar) on Feb 03, 2006 at 13:55 UTC
    Maybe I get it wrong, but it seems to me that tamaguchi asked how to create files, not open.

      The example he gave was using shell redirection to capture the output of his script. And even so, it's overkill to spawn another shell when a simple { open( my $fh, ">", $newfile ) or die "open $newfile: $!\n" } would suffice.

      $ mkdir foo $ cd foo/ $ perl -e 'open F, ">bar"' $ ls bar