Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Re: Re: recomendations needed for type of data structure

by integral (Hermit)
on Feb 17, 2003 at 20:26 UTC ( #236102=note: print w/replies, xml ) Need Help??


in reply to Re: Re: recomendations needed for type of data structure
in thread recomendations needed for type of data structure

This is because the array of traps is stored as a reference to an anonymous array in one of the keys (TRAP_LIST) of the anonymous hash in the TRAPS key of the %$hash. This means that when you try to print the keys and values of the %{$hash->{TRAPS}} hash, you get the stringified array reference. To solve this you could add a special case to the output loop which prints the contents of the array.
# this handles ARRAYs and HASHes # you may want to use Data::Dumper for debugging however # the final code for processing the data structure will # also be less generic than this code. if (ref $value eq 'ARRAY') { print "$key => (@$value)\n"; } elsif (ref $value eq 'HASH') { print "$key => (%$value)\n"; } else print "$key => $value\n"; }

--
integral, resident of freenode's #perl

Replies are listed 'Best First'.
Re: Re: Re: Re: recomendations needed for type of data structure
by Anonymous Monk on Feb 17, 2003 at 21:09 UTC
    Thank you Integral
    One last question,

    What would the syntax be if I wanted to simply print out?:

    Varbind: 1.3.6.1.2.1.2.2.1.1
    Thanks again, I'm slowly piecing this all together.
      Well assuming that $key = 'Varbind' and that $value is an array ref containing each part of the id, then you can use join:
      print "$key: ".join('.',@$value)."\n";

      When you use an array in a string (like "@a"), perl translates this internally into join($", @a), one can see this if you turn perl's bytecode back into source code using B::Deparse.

      --
      integral, resident of freenode's #perl
      
Re: Re: Re: Re: recomendations needed for type of data structure
by steves (Curate) on Feb 17, 2003 at 21:49 UTC

    Exactly ... that's part of what needs finishing. My laziness got the best of my hubris. 8-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://236102]
help
Chatterbox?
[Corion]: Last year we renamed everybody with a name collision to "Alice". This year, we're renaming the remaining collisions to 'Bob' ;-)
[stevieb]: sigh... should have looked to see if version 2.36.1 was higher or lower than 2.36 when uploading to CPAN :/
[Corion]: :-D
[stevieb]: I suppose I'll have to delete the 2.36 ver, then re-upload 2.36.1 and 2.36.2, and re-version 2.36 as 2.36.0

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (12)
As of 2017-01-19 14:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (170 votes). Check out past polls.