Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: need help with Tie::Judy

by expo1967 (Sexton)
on Dec 05, 2020 at 20:11 UTC ( [id://11124726]=note: print w/replies, xml ) Need Help??


in reply to Re: need help with Tie::Judy
in thread need help with Tie::Judy

Yes I have looked at the documentation for Tie::Judy and the example code is not complete. I need a complete functioning example.

Replies are listed 'Best First'.
Re^3: need help with Tie::Judy
by LanX (Saint) on Dec 05, 2020 at 21:34 UTC
    > I need a complete functioning example.

    try this

    use Tie::Judy; tie %fruit_color, 'Tie::Judy';
    A hash represents a set of key/value pairs:
    my %fruit_color = ("apple", "red", "banana", "yellow");
    You can use whitespace and the '=>' operator to lay them out more nicely:
    my %fruit_color = ( apple => "red", banana => "yellow", );
    To get at hash elements:
    $fruit_color{"apple"}; # gives "red"
    You can get at lists of keys and values with keys() and values().
    my @fruits = keys %fruit_color; my @colors = values %fruit_color;

    see also Re: need help with Tie::Judy

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      I'm trying to understand what is happen with the sample code LanX has provided...

      The command tie %fruit_color, 'Tie::Judy'; ties the associative array* %fruit_color to the class. From this point on, when %fruit_color is used, instead of the default Perl behaviour, the implementation is handled by Tie::Judy which implements alternative methods to the default methods used by Perl. In this case it does the same thing in a different way.

      Is that something like correct?

      * I deliberately didn't refer to %fruit_color here as a hash because in this case it is a Judy Array which is not a hash but another example of the same type of storage.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11124726]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-25 05:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found