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

Mikhael Goikhman migo at homemail.com
Mon Nov 15 10:10:06 PST 2004

On 15 Nov 2004 19:09:25 +0200, Gaal Yahas wrote:
> On Mon, Nov 15, 2004 at 06:52:55PM +0200, Offer Kaye wrote:
> > 
> > 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
> perlbug?

I am not sure where you see a bug in perlrun man page. Compare:

  /bin/echo -e 'a\000b\000c\000d' | perl -n -e 'print "[$_]\n"' | cat -A
  /bin/echo -e 'a\000b\000c\000d' | perl -n0 -e 'print "[$_]\n"' | cat -A
  /bin/echo -e 'a\000b\000c\000d' | perl -n00 -e 'print "[$_]\n"' | cat -A
  /bin/echo -e 'a\000b\000c\000d' | perl -n0x0 -e 'print "[$_]\n"' | cat -A
  /bin/echo -e 'a\000b\000c\000d' | perl -n0777 -e 'print "[$_]\n"' | cat -A

All works as advertised. And if you want the output of the first and the
last commands to be different, replace "c" with "\012" in echo.


perl -e 'print+chr(64+hex)for+split//,d9b815c07f9b8d1e'

More information about the Perl mailing list