El Monday 25 August 2008 14:30:14 Moon, John va escriure:
> > How can I use a "constant" as a hash key?
> >
> > $ perl -e 'use constant CAT=>A;
> >
> >> $hash{CAT} = q{Bobby};
> >> $hash{"CAT"} = q{Muffy};
> >> $hash{'CAT'} = q{Fluffy};
> >> $hash{qq{CAT}} = q{Tuffy};
> >> print "$_ = $hash{$_}\n" foreach (keys %hash);'
> >
> > CAT = Tuffy
> > $
> >
> > Want...
> >
> > A=Bobby
>
> See the "Not-so-symbolic references" section of the perlref.pod man page
>
> for some hints:
>
> perldoc perlref
>
>
>
> John
> --
> Perl isn't a toolbox, but a small machine shop where you
> can special-order certain sorts of tools at low cost and
> in short order.                            -- Larry Wall
>
>
> [>>] Thank you...
>
> >>perl -we 'use constant CAT=>a; $hash{+CAT} = q{Bobby}; print "$_ =
>
> $hash{$_}\n" foreach (keys %hash);'
>
> jwm

key must be always unique.

-- 
Xavier Mas

                
______________________________________________ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
http://es.voice.yahoo.com


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to