develooper Front page | perl.fwp | Postings from December 2001

Re: Sorted Code

Thread Previous | Thread Next
Ilmari Karonen
December 14, 2001 11:55
Re: Sorted Code
Message ID:

On Thu, 13 Dec 2001, Jeff 'japhy' Pinyan wrote:
> On Dec 14, said:
> >what is the longest piece of perl code $c which is "perl -c" correct with
> >the requirement that each character in $c is ord-less than the next one.  ie
>  !&'()*+-.0123456789<=>@ABCDEFGHIJKLMNOPQRSTUVWXYZ^_abcdefghijklmnopqrstuvwxyz{}
> Note the leading space.  I think that's as good as you'll get.

I think I can do better, quite easily:


Note the leading space, again.  That's using only the printable ASCII
characters, of course.  Leading tab, newline, etc. are easy to add, as
are trailing 8-bit characters.  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.

Ilmari Karonen -
"I'd say the number of people in the world who really understand Perl's
 regex code is about three, plus or minus four."
                                -- Larry Wall on the perl5-porters list

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About