Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
so dealing with files originating from other OS needs the ability to change the value of \n
I would say "to change the value of $/". -0 certainly doesn't change \n.

There are also some funky details about how -0 works. First of all, -0[octal] is limited to 3 following octal digits. Anything beyond that is interpreted as a new bundled switch (e.g. -07770 is equivalent to -0777 -0 (which is equivalent to just -0)).

-0 with no following octal digits will set $/ to "\0", the null character. As you say, -00 does paragraph mode ($/ = "") instead. This applies to -000 and -0000 also; as above, -00000 etc is interpreted as two separate switches where the first is meaningless, creating the pleasant cycle:
-0\0 record separator
-00paragraph mode
-000paragraph mode
-0000paragraph mode
-00000\0 record separator
-000000paragraph mode
-0000000paragraph mode
-00000000paragraph mode
-000000000\0 record separator
-0000000000paragraph mode

Not just -0777, but any attempt to specify an octal character greater than 0377 (255 decimal), will trigger slurp mode.

And starting with 5.8.1, -0 will allow hex characters to be specified like -0x1ff (but you can't bundle it with other switches like -0x1ffw; for backward compatibility, that is interpreted as -0 -x1ffw instead of -0x1ff -w (see perlrun for details on the -x switch)). Any number of hexidecimal digits are permitted, but only the low 32-bits are used. This allows specifying any unicode character as the record separator. Paragraph mode or slurp mode cannot be specified with -0x; -0x0 sets $/ to "\0", not "", -0x1ff (the "equivalent" of -0777) sets $/ to "\x{1ff}", not undef.

-0x actually allows an extra "x" or "0x" after the first one (e.g. -0x0x0d or -0xx0); this can be construed as a bug.

In reply to Re: Uncommon* but Useful Perl Command Line Options (for one-liners) by ysth
in thread Uncommon* but Useful Perl Command Line Options for One-liners by Sol-Invictus

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (4)
    As of 2020-04-06 02:34 GMT
    Find Nodes?
      Voting Booth?
      The most amusing oxymoron is:

      Results (36 votes). Check out past polls.