Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Hash not getting updated

by CharlesClarkson (Curate)
on May 03, 2005 at 14:23 UTC ( #453592=note: print w/replies, xml ) Need Help??


in reply to Re^2: Hash not getting updated
in thread Hash not getting updated

Have you tried it like that?

#!/usr/bin/perl use strict; use warnings; use Data::Dumper 'Dumper'; my @colors = qw( white yellow green ); my %hash; $hash{ @colors } = @colors; print Dumper \%hash; __END__

I get this in perl 5.8.6:

$VAR1 = { '3' => 3 };

Perl assumes you want to evaluate the array in scalar context. Better to stick to the same notation everyone else uses for hash slices.

HTH,
Charles

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://453592]
help
Chatterbox?
[stevieb]: yeah. This is my build/test software that manipulates perlbrew/ berrybrew, and runs all unit tests of a project against all installed versions, including testing a dist against all of it's current revdeps. A lot of tests it runs for itself:)
[stevieb]: testing the test build system, essentially

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2017-03-26 22:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (315 votes). Check out past polls.