in reply to One to one file output idiom

as I suggested in the CB do the open explictely:

I'm not good with one-liners, but this seems to do the job on Windows

>perl -pE"open OUT => qq(>$ARGV.ext); select (OUT); s/bla/drivel/" a b + c

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Replies are listed 'Best First'.
Re^2: One to one file output idiom
by choroba (Cardinal) on Jan 15, 2020 at 18:19 UTC
    Does it work if the files have more than one line? It seems the open overwrites the output file every time...

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      No, but >> for append does, though you must be sure the OUT-file doesn't exist already

      C:\tmp\files>perl -pE"open STDOUT=>qq(>>$ARGV.ext); s/bla/drivel/" a b + c

      There was a hack with Eskimo kiss } { in the -e but as I said I'm not experienced with one liners.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

        You can't really use an eskimo kiss with -p. And it's equivalent to an END block so I'm not sure how that would help here.

        But the open STDOUT, qq(>$ARGV.ext); version does work when slurping the files with -p00, for example in the case of a global substitution.