[Israel.pm] difference between -0 and -0777

Gaal Yahas gaal at forum2.org
Mon Nov 15 09:09:25 PST 2004

On Mon, Nov 15, 2004 at 06:52:55PM +0200, Offer Kaye wrote:
> Hi,
> According to "perldoc perlrun", using the "-0" switch without any
> digits uses the null char as separator, and using -0777 causes Perl to
> slurp in files whole because there is no legal char with that value.
> My question is, what in practice is the difference between the two
> values. As far as I could tell, these two commands do the same thing:
> perl -0       -pi -e's/s1/s2/g' file
> perl -0777 -pi -e's/s1/s2/g' file
> Is there a difference at all between using "-0" and "-0777"?

They mean the NUL character, ASCII 0. Compare the outputs:

     /bin/echo -e 'a\000b\000c\000d' | cat -A
     /bin/echo -e 'a\000b\000c\000d' | perl -nl0 -e 'print ">>$_<<\n"'
     /bin/echo -e 'a\000b\000c\000d' | perl -nl000 -e 'print ">>$_<<\n"'

I'd consider this to be a bug in perlrun; do you feel like sending a

Gaal Yahas <gaal at forum2.org>

More information about the Perl mailing list