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

> 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

Replies are listed 'Best First'.
Re^4: need help with Tie::Judy
by Bod (Parson) on Dec 06, 2020 at 01:02 UTC

    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.