Lingua::Pangram

Smylers Belfast-PM at stripey.com
Fri Jan 25 14:53:45 CST 2002


Marty wrote:

> On Thu Jan 24 19:35:24 2002, Smylers wrote:
>
> >   perl -ne'@$_{/[a-z]/gi}=1;%$_>25&&print'  # 40
> >
> > It relies on the hashing sticking each letter of the alphabet in a
> > separate bucket but upper- and lower-case versions of the same letter in
> > the same bucket.  This seems to work on 5.005_03; I haven't test it on
> > anything else.
>
> Fail my test with 5.6.1: the upper case letters don't quite work,
> although the lower case behaviour is the same.

Ah.  It was a discovery I made by chance and seemed exactly the sort of
thing that shouldn't be relied upon.

> >   perl -ne'my%k;@k{/[a-z]/gi}=1;%k>25&&print'  # 43
>
> And that version will run under strict; your previous version won't,
> and trying it should give a clue to why it works at all. ...  You are
> using (evil) symbolic refererences.  That is, if $_ contains the
> string "this is a test", then the name of your hash variable is
> effectivly %'this is a test'.

Oooh.  I'd forgotten all about the existence of symbolic refs, never
having seen the point of them, so forgot all about them when I used them
by mistake.

> -Mstrict should explain it for you.

So it does!  Ta.

Smylers




More information about the Belfast-pm mailing list