in reply to This fails mysteriously everytime...
A tip for future reference.
In every control structure, if you have a limited number of options put an "else" case in that dies with an informative message. That will make this kind of error much easier to notice and track down...
In Section
Seekers of Perl Wisdom