Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Setting dollarslash to 0777 doesn't work?

Expand Messages
  • Jeff Pinyan
    ... The *perlrun *document states that the numeric value of the *-0*command-line feature is an *octal* value. (You can use a hexadecimal value by using
    Message 1 of 2 , Jul 18 10:26 AM
    • 0 Attachment
      On Wed, Jul 15, 2009 at 9:31 AM, Kelly Jones <kelly.terry.jones@...>wrote:

      > According to "man perlrun", the "-0777" option sets $/ to 0777 and
      > slurps files whole. This works fine.
      >
      > However, when I did 'local $/="0777"' in a script, it usually worked,
      > but sometimes failed and only slurped part of the file.
      >

      The *perlrun *document states that the numeric value of the
      *-0*command-line feature is an
      *octal* value. (You can use a hexadecimal value by using *-0x*.) Thus, *
      -0123* is not setting $/ equal to "123" or "0123", but rather to the
      character denoted by the octal value 123. Octal 123 = *3* + *2**8 + *1**64
      = 83, which is "S".

      The *perlrun* document also makes clear that "the value *0777* will cause
      Perl to slurp files whole because there is no legal byte with that value."
      Thus, the *-0777* command-line feature is a special case.

      The only reason $/ = "0777" *appeared* to work for you is that, if the file
      you were reading never had the sequence "0777" in it, it would read the
      whole file at once. You could just have easily used $/ = "THIS STRING NEVER
      OCCURS IN THE FILE", so long as you were sure "THIS STRING NEVER OCCURS IN
      THE FILE" in fact *never* occurs in the files you are reading from.


      > Changing this to "local $/ = undef" worked fine.
      >
      > Why?


      Because that is what *-0777* is doing, setting $/ to undef. That's what you
      should do.

      --
      The Cross Reference - http://thecrossreference.blogspot.com/
      Critical Mass (The Science of the Liturgy) -
      http://romanliturgy.blogspot.com/

      [Mary said,] "Do whatever he tells you." ~ John 2:5


      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.