I was looking at your code, and found this little typo which might cause some unexpected bugs!
Great module, by the way! I've written this same kind of code so many times I can't believe I haven't already written the same module!
Thanks! I've incorporated your changes (plus a tweak to avoid a warning) and added a test which I should have written in the first place. The changes will be in version 0.4 should be in CPAN shortly.