Setting dollarslash to 0777 doesn't work?
- 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.
Changing this to "local $/ = undef" worked fine.
We're just a Bunch Of Regular Guys, a collective group that's trying
to understand and assimilate technology. We feel that resistance to
new ideas and technology is unwise and ultimately futile.
- 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 andThe *perlrun *document states that the numeric value of the
> 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.
*-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.Because that is what *-0777* is doing, setting $/ to undef. That's what you
The Cross Reference - http://thecrossreference.blogspot.com/
Critical Mass (The Science of the Liturgy) -
[Mary said,] "Do whatever he tells you." ~ John 2:5
[Non-text portions of this message have been removed]