Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^4: One to one file output idiom

by Eily (Monsignor)
on Jan 16, 2020 at 09:28 UTC ( #11111474=note: print w/replies, xml ) Need Help??


in reply to Re^3: One to one file output idiom
in thread One to one file output idiom

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.

Replies are listed 'Best First'.
Re^5: One to one file output idiom
by LanX (Archbishop) on Jan 16, 2020 at 20:34 UTC
    > 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.

    -p00 irritates me, I suppose you mean the equivalent to -p -00 , which doesn't mean slurping the whole file, but reading by paragraph.

    Slurping is bound to anything bigger -0400

    C:\tmp\files>type x 1:onebla 2:onebla 3:onebla 1:twobla 2:twobla 3:twobla 1:threebla 2:threebla 3:threebla C:\tmp\files>perl -n00 -E"say'>>';print;say'<<'" x >> 1:onebla 2:onebla 3:onebla << >> 1:twobla 2:twobla 3:twobla << >> 1:threebla 2:threebla 3:threebla << C:\tmp\files>perl -n0777 -E"say'>>';print;say'<<'" x >> 1:onebla 2:onebla 3:onebla 1:twobla 2:twobla 3:twobla 1:threebla 2:threebla 3:threebla <<

    from perlrun

    -0[octal/hexadecimal]

    specifies the input record separator ( $/ ) as an octal or hexadecimal number. If there are no digits, the null character is the separator. Other switches may precede or follow the digits. For example, if you have a version of find which can print filenames terminated by the null character, you can say this:

    1. find . -name '*.orig' -print0 | perl -n0e unlink

    The special value 00 will cause Perl to slurp files in paragraph mode. Any value 0400 or above will cause Perl to slurp files whole, but by convention the value 0777 is the one normally used for this purpose.

    You can also specify the separator character using hexadecimal notation: -0xHHH..., where the H are valid hexadecimal digits. Unlike the octal form, this one may be used to specify any Unicode character, even those beyond 0xFF. So if you really want a record separator of 0777, specify it as -0x1FF. (This means that you cannot use the -x option with a directory name that consists of hexadecimal digits, or else Perl will think you have specified a hex number to -0.)

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

      Yup my bad, it should have been -0777, didn't test what I was saying :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11111474]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2020-05-26 13:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (150 votes). Check out past polls.

    Notices?