Front page | perl.fwp |
Postings from December 2001
Re: Sorted Code
Thread Previous
|
Thread Next
From:
Philippe 'BooK' Bruhat
Date:
December 14, 2001 12:13
Subject:
Re: Sorted Code
Message ID:
Pine.LNX.4.21.0112142112410.2389-100000@rose.home.bruhat.net
On Fri, 14 Dec 2001, Ilmari Karonen wrote:
> But surprisingly enough, the following
> also outputs "- syntax OK" for at least versions 5.005_03 and 5.7.1:
>
> perl -e 'print map chr, 0, 4 .. 255' | perl -c
>
> That's a total of 253 out of 256 characters, which seems unbeatable.
>
> No, I've no idea why that works. Explanations gladly accepted.
Erm, according to the ascii man page:
Oct Dec Hex Char Oct Dec Hex Char
------------------------------------------------------------
000 0 00 NUL '\0' 100 64 40 @
001 1 01 SOH 101 65 41 A
002 2 02 STX 102 66 42 B
003 3 03 ETX 103 67 43 C
-> 004 4 04 EOT 104 68 44 D
005 5 05 ENQ 105 69 45 E
006 6 06 ACK 106 70 46 F
This is EOT, End Of Text (aka ^D). So your script is in fact \0.
I guess perl -O=Deparse returns '???' (a constant in void context:
optimized away)
$ perl -e 'print map chr, 0, 4 .. 255' | perl -MO=Deparse
- syntax OK
Mmm. So I am wrong about the NUL char. But I am pretty confident about ^D.
In fact it's
perl -MO=Deparse -e '\0'
'???';
- syntax OK
that does what I thought.
You can test the embedded ^D stuff with this file:
print "ok";
^D <- embedded Ctrl-D: one char. Use ^V^D to input this in vi.
print "nok";
$ perl file
ok
--
Philippe "BooK" Bruhat
The friends we make and the friends we lose are all better than the friends
who want to make us lose. (Moral from Groo The Wanderer #1 (Pacific))
Thread Previous
|
Thread Next