On Nov 24, 2005, at 12:40, Xavier Noria wrote:
Just in case, looking at the last 1s I wonder whether you need that
structure, or would it be more concise to have a hash where the
keys can be arrays. The usage of such a hash would be
$h{['A', 'B', 'C', 1, 2]} = 1;
If that was the case there are some modules on CPAN that provide
them, like Tie::ListKeyedHash or Hash::MultiKey.
Just wanted to add that as your keys may have different lengths I
would recommend Hash::MultiKey indeed, since Tie::ListKeyedHash has
this problem:
% cat foo.pl
use Tie::ListKeyedHash;
tie my %h, 'Tie::ListKeyedHash';
$h{['foo']} = 1;
$h{['foo', 'bar', 'baz']} = 2;
% perl foo.pl
Can't use string ("1") as a HASH ref while "strict refs" in use at
/usr/local/lib/perl5/site_perl/5.8.7/Tie/ListKeyedHash.pm line 296.
Hash::MultiKey has no limitation whatsoever and, additionally, deals
with empty fields in regular $h{'A', 'B',,,} correctly. (It has the
extra property that I wrote it, but that is secondary.)
-- fxn
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>