Subject: | $@ |
this code will cause _create_sub_from_RE to die unnecessarily.
use strict;
use Data::FormValidator::Results;
# this works
Data::FormValidator::Results::_create_sub_from_RE(qr/(this|that)/);
# this doesn't
$@ = 'HEY!';
Data::FormValidator::Results::_create_sub_from_RE(qr/(this|that)/);
_create_sub_from_RE doesn't expect $@ to have a value. I encountered this
while combining URI::Find to check url's. Seems that URI::Find leaves a
value in $@ if a url fails with a call to LWP::Simple::head. Then the next call to _create_sub_from_RE chokes.
It was quite deceiving as to where the problem was since there is all
that scary substr($_[0], $-[0], $+[0] - $-[0]). But I think that is only
there to avoid using $&.
read about that at http://www.perldoc.com/perl5.6/pod/perlvar.html
For now, I put an 'undef $@' in the _create_sub_from_RE and it works ok.
Don't know if that is the best approach. Perhaps local it?
cheers
Kev