For completeness, the arrow stringifies LHS *almost* always...

If your keys start with a number, but also have other characters following
them, or are just completely 'odd' (ie, \W), you must quote them.

For example:
%foo = ( "34foo" => "bar" );
or even
%foo = ( '#)$*.#@' => "bar" );

note that double quotes allow intperlolation, whereas single quotes don't
and of course, the second case may be concidered Very Bad Thing To Do (tm);
keep your hash keys at least half way sane.

read more about these things at: http://www.sharemation.com/~perl/tut

hth,

Jos Boumans


----- Original Message -----
From: "Brett W. McCoy" <[EMAIL PROTECTED]>
To: "Pozsar Balazs" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, July 03, 2001 7:12 PM
Subject: RE: pointers to subs?


> On Tue, 3 Jul 2001, Pozsar Balazs wrote:
>
> > What's the difference between these two?:
> >
> >   %actions = (
> >     login => \&welcome,
> >     authent => \&checkpass,
> >   );
> > and
> >   %actions = (
> >     "login" => \&welcome,
> >     "authent" => \&checkpass,
> >   );
>
> Nothing.  If you use the => operator, quotes around the keys are not
> required.  Quotes are also not required when using single word keys hwne
> retrieving a value:
>
> $actions{login}->();
>
> -- Brett
>    http://www.chapelperilous.net/btfwk/
> ------------------------------------------------------------------------
> An investment in knowledge always pays the best interest.
> -- Benjamin Franklin
>
>

Reply via email to