hash of hashes

Discussion in 'Perl Misc' started by John, Aug 14, 2009.

  1. John

    John Guest

    Hi

    Cannot work this one out.

    The following works OK:

    my $test1=$der->encode({type => 'sequence',
    value => [{type => 'integer', value => 55},{type => 'string', value =>
    'HALLO'}]
    });

    Rather than placing the hash in the routine call I want to place it outside
    and call it $der->encode(%hash);

    my %hash;
    $hash{type}='sequence';
    $hash{value}{type}='integer';
    $hash{value}{value}='55';
    if I now say
    $hash{value}{type}='string';
    $hash{value}{value}='hallo';
    it will overwite 'integer' and '55'

    How do I get around that?

    Regards
    John
     
    John, Aug 14, 2009
    #1
    1. Advertising

  2. John

    J. Gleixner Guest

    John wrote:
    > Hi
    >
    > Cannot work this one out.
    >
    > The following works OK:
    >
    > my $test1=$der->encode({type => 'sequence',
    > value => [{type => 'integer', value => 55},{type => 'string', value =>
    > 'HALLO'}]
    > });
    >
    > Rather than placing the hash in the routine call I want to place it outside
    > and call it $der->encode(%hash);
    >
    > my %hash;
    > $hash{type}='sequence';
    > $hash{value}{type}='integer';
    > $hash{value}{value}='55';
    > if I now say
    > $hash{value}{type}='string';
    > $hash{value}{value}='hallo';
    > it will overwite 'integer' and '55'
    >
    > How do I get around that?
    >
    > Regards
    > John
    >
    >


    perldoc perldsc

    push( @{ $hash{ 'value' } },
    { type=> 'integer', value => '55' },
    { type=> 'string', value => 'hallo' } );
     
    J. Gleixner, Aug 14, 2009
    #2
    1. Advertising

  3. John

    John Guest

    "J. Gleixner" <> wrote in message
    news:4a85953c$0$1325$...
    > John wrote:
    >> Hi
    >>
    >> Cannot work this one out.
    >>
    >> The following works OK:
    >>
    >> my $test1=$der->encode({type => 'sequence',
    >> value => [{type => 'integer', value => 55},{type => 'string', value =>
    >> 'HALLO'}]
    >> });
    >>
    >> Rather than placing the hash in the routine call I want to place it
    >> outside and call it $der->encode(%hash);
    >>
    >> my %hash;
    >> $hash{type}='sequence';
    >> $hash{value}{type}='integer';
    >> $hash{value}{value}='55';
    >> if I now say
    >> $hash{value}{type}='string';
    >> $hash{value}{value}='hallo';
    >> it will overwite 'integer' and '55'
    >>
    >> How do I get around that?
    >>
    >> Regards
    >> John
    >>
    >>

    >
    > perldoc perldsc
    >
    > push( @{ $hash{ 'value' } },
    > { type=> 'integer', value => '55' },



    Many thanks.
    Regards
    John



    > { type=> 'string', value => 'hallo' } );
     
    John, Aug 14, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rp
    Replies:
    1
    Views:
    597
    red floyd
    Nov 10, 2011
  2. Scott  Gilpin
    Replies:
    2
    Views:
    238
  3. Perl Learner

    Hashes of hashes or just one hash ?

    Perl Learner, Jun 8, 2005, in forum: Perl Misc
    Replies:
    11
    Views:
    236
  4. Tim O'Donovan

    Hash of hashes, of hashes, of arrays of hashes

    Tim O'Donovan, Oct 27, 2005, in forum: Perl Misc
    Replies:
    5
    Views:
    237
  5. Replies:
    3
    Views:
    234
Loading...

Share This Page