On Thu, 13 Dec 2001, Jeff 'japhy' Pinyan wrote:
> On Dec 14, [EMAIL PROTECTED] 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


Reply via email to