in reply to Re: Multiple Hashes are stressing me
in thread Multiple Hashes are stressing me

Is it that simple?

Man, I'm really embarassed...

Thanks a lot, Blake. I'll test it tomorrow at work.

Best Regards,

Er Galvão Abbott
a.k.a. Lobo, DaWolf
Webdeveloper
  • Comment on Re: Re: Multiple Hashes are stressing me

Replies are listed 'Best First'.
Re: Re: Re: Multiple Hashes are stressing me
by blakem (Monsignor) on Oct 09, 2001 at 08:49 UTC
    Whats actually happening is that the hashes are flattened into a list, then this list is assigned to a new hash. So, %h1 and %h4 wind up with the same contents below:
    #!/usr/bin/perl -wT use strict; my @a1 = ('jan','January','feb','February'); my @a2 = ('mar','March', 'apr','April'); my %h1 = (@a1, @a2); # Two arrays become one h +ash my %h2 = ('jan','January','feb','February'); my %h3 = ('mar'=>'March' ,'apr'=>'April'); # '=>' is really just a c +omma my %h4 = (%h2,%h3); # Hashes get flattened an +d behave # nearly the same as the +two # arrays did above print "h1\n"; print "\t$_ => $h1{$_}\n" for (sort keys %h1); print "h4\n"; print "\t$_ => $h4{$_}\n" for (sort keys %h4); =OUTPUT h1 apr => April feb => February jan => January mar => March h4 apr => April feb => February jan => January mar => March

    -Blake

Re: Re: Re: Multiple Hashes are stressing me
by John M. Dlugosz (Monsignor) on Oct 09, 2001 at 07:23 UTC
    Yes, it gets easier once you realize that you don't have to micromanage your data, like in C.