Re: [code-review] Tie::Hash::RegexKeys
Peter Scott <[email protected]> Tue, 13 Jan 2004 09:13:02 -0800
| Newsgroups | gmane.comp.lang.perl.code-review-ladder |
|---|---|
| Message-ID | <[email protected]> |
At 09:30 AM 1/13/2004 +0100, Xavier Noria wrote:
>On Jan 13, 2004, at 3:28 AM, Peter Scott wrote:
>
>>I've created another module intended for CPAN at
>>http://www.psdt.com/Tie-Hash-RegexKeys-0.01.tar.gz pending review
>>from folks here. This allows you to use regexen as hash keys and
>>operate on the elements with matching keys. It's not fast when you
>>do that, 'cos it scans through potentially all the keys, but it can
>>be useful anyway.
>
>If I understand the code correctly, $h{/regex/} = $value updates
>$value in all the entries whose key matches /regex/. That's right. But
>$h{/regex/} returns just one value, and which one is undefined because
>it is the first one in hash order among the ones whose key matches /regex/.
>
>I think I would expect a list from FETCH, or at least a list if wantarray.
Yes, I really wanted that too. But it can't be done. Now I see the
existing modules for doing this :-( I found Dave Cross' explanation and
workaround:
http://search.cpan.org/~davecross/Tie-Hash-Regex-0.09/Regex.pm
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com/
*** New! *** http://www.perlmedic.com/