Skip Menu |

This queue is for tickets about the Data-FormValidator CPAN distribution.

Maintainer(s)' notes

This is the bug queue for Data::FormValidator.

Report information
The Basics
Id: 5449
Status: resolved
Priority: 0/
Queue: Data-FormValidator

People
Owner: Nobody in particular
Requestors: kevin [...] ripe.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 3.50
Fixed in: (no value)



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
I just realised a better solution than 'undef $@'. Here is the code snippet from _create_sub_from_RE else { $sub = eval 'sub { $_[0] =~ '.$re.$return_code. '}'; } die "Error compiling regular expression $re: $@" if $@; If the die statment was moved inside the else block then it would be find. It is the only eval in the subroutine and the die is meant for that. eval will reset $@ so no problems. cheers Kev
Date: Wed, 25 Feb 2004 20:07:41 -0500
From: Mark Stosberg <mark [...] summersault.com>
To: Guest via RT <bug-Data-FormValidator [...] rt.cpan.org>
Subject: Re: [cpan #5449] $@ in DFV
RT-Send-Cc:
On Wed, Feb 25, 2004 at 05:15:45PM -0500, Guest via RT wrote: Show quoted text
> > _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?
Thanks for the report. I have now moved the "die" into the "else" clause as you suggest. Should be out soon. And you are right-- the code above is scary. I didn't write it and don't really understand it, honestly. A clarity patch would be accepted. Mark -- http://mark.stosberg.com/