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

Re: Sorted Code

Thread Previous | Thread Next
From:
Ilmari Karonen
Date:
December 14, 2001 11:55
Subject:
Re: Sorted Code
Message ID:
Pine.SOL.3.96.1011214214310.29236C-100000@simpukka

On Thu, 13 Dec 2001, Jeff 'japhy' Pinyan wrote:
> On Dec 14, Alistair.McGlinchy@marks-and-spencer.com 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:

 #$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

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 - http://www.sci.fi/~iltzu/
"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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About