Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added test for 5.20 where regex should return more than one #1

Merged
merged 1 commit into from
Aug 17, 2015

Conversation

vanHoesel
Copy link

Sorry Dave...

now your tests fail under 5.20

maybe the slices.t should have a 5.20 check in it before

davorg added a commit that referenced this pull request Aug 17, 2015
added test for 5.20 where regex should return more than one
@davorg davorg merged commit 4c1267b into davorg-cpan:master Aug 17, 2015
@vanHoesel
Copy link
Author

sadly enough, I now have to ensure that I will do the correct thing with Tie::Hash::LanguageRange

@davorg
Copy link
Collaborator

davorg commented Aug 17, 2015

Having had a quick look at this, I remember what the problem was and why it doesn't work.

FETCH is always called in scalar context - as it is only ever expected to return a single value. With a standard hash (actually a Tie::StdHash), if you call it as a hash slice (@hash{qw[foo bar]}) then FETCH is called twice - once for each key in the slice. But with Tie::Hash::Regex, a single call can, in theory, return multiple values (@hash(qw/./), for example should return all values from the hash), but Perl just doesn't expect that to be an option - so the tie interface just doesn't support it.

I remember wrestling with this when I first implemented the module. But at the time I just gave up (and pretended that the problem didn't exist - which is why there's no slice tests in the existing code).

I can't see any way around it. But I might run it past london.pm and see if anyone there can come up with anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants