Re: "use constant" as hash key

2008-08-25 Thread Xavier Mas
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"

RE: "use constant" as hash key

2008-08-25 Thread Moon, John
> 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 "

Re: "use constant" as hash key

2008-08-23 Thread Peter Scott
On Thu, 21 Aug 2008 14:15:57 -0400, Moon, John wrote: > How can I use a "constant" as a hash key? Having to know the answer to this is one of the reasons that 'use constant' is considered an inferior practice compared to use Readonly; Readonly my $CAT => 'A'; -- Peter Scott http

Re: "use constant" as hash key

2008-08-23 Thread Dr.Ruud
"Moon, John" schreef: > How can I use a "constant" as a hash key? #!/usr/bin/perl use strict; use warnings; use Data::Dumper; use constant FOO => 'bar'; my %hash; $hash{ FOO } = 'one'; $hash{ +FOO } = 'two'; $hash{ 'FOO' } = 'three'; $hash{ -FOO } = 'four'; $hash{

Re: "use constant" as hash key

2008-08-22 Thread John W. Krahn
Rob Dixon wrote: Moon, John wrote: 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 I

Re: "use constant" as hash key

2008-08-22 Thread Rob Dixon
Moon, John wrote: > > 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... >

Re: "use constant" as hash key

2008-08-22 Thread John W. Krahn
Moon, John wrote: 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-sym

"use constant" as hash key

2008-08-22 Thread Moon, John
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 John W Moon -- To unsubscribe,