sudeep has asked for the wisdom of the Perl Monks concerning the following question:

hey, I wanted to know how Set::Scalar can be used in the same way as hashes my question is how can we set the values to the key and also whenever I wanted to replace the values with the new value using this Set::Scalar how can I do that.
For example now I have a key num_row and the values are '12350','archive' now how can I assign these values to the same key using Set::Sca +lar and how can I print those values. Can any one please give me an idea about this. Thank you.

Replies are listed 'Best First'.
Re: using Set::Scalar
by ysth (Canon) on Feb 19, 2008 at 22:45 UTC
    Set::Scalar manages an unordered collection of values; it doesn't have anything corresponding to keys.

    The simplest answer to what you seem to want would be a hash of arrays:

    my %data; # create a key num_row with two values @{$data{num_row}} = ( '12350', 'archive' ); # add another value push @{$data{num_row}}, '613'; foreach my $key (keys %data) { print "Examining key $key\n"; foreach my $val (@{$data{$key}}) { print "value: $val\n"; } } print "num_row's 2nd value is $data{num_row}[1]\n";
A reply falls below the community's threshold of quality. You may see it by logging in.