Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

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

Report information
The Basics
Id: 4511
Status: resolved
Worked: 30 min
Priority: 0/
Queue: Data-Compare

People
Owner: dcantrell [...] cpan.org
Requestors: mike [...] very.puzzling.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.02
Fixed in: (no value)



Subject: Can not compare compiled regexps
Data::Compare version 0.02 does not correctly compare regexps created by qr//. For example: use Data::Compare; $a = qr/abc/; $b = $a; print Data::Compare::Compare($a, $b) ? "Different\n" : "Same\n"; The output is: Use of uninitialized value in string eq at /usr/lib/perl5/site_perl/5.8.0/Data/Compare.pm line 94. Use of uninitialized value in string eq at /usr/lib/perl5/site_perl/5.8.0/Data/Compare.pm line 94. Use of uninitialized value in string eq at /usr/lib/perl5/site_perl/5.8.0/Data/Compare.pm line 94. Use of uninitialized value in string eq at /usr/lib/perl5/site_perl/5.8.0/Data/Compare.pm line 94. Use of uninitialized value in string eq at /usr/lib/perl5/site_perl/5.8.0/Data/Compare.pm line 94. Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/site_perl/5.8.0/Data/Compare.pm line 116. Can't handle type. at -e line 1 This also occurs with perl 5.00503. I don't think there is any way to compare regexps semantically -- ie, they would match exactly the same set of strings -- however a reasonable approximation can be obtained by stringifying them, then comparing the strings. The attached patch adds this functionality.
--- Compare.pm.orig 2003-11-28 12:54:19.000000000 +1100 +++ Compare.pm 2003-11-28 12:54:40.000000000 +1100 @@ -80,6 +80,9 @@ } 1; } + elsif ($refx eq 'Regexp') { + Compare($x . '', $y . ''); + } elsif ($refx eq 'REF') { 0; }
RT-Send-CC: fta [...] sofaraway.org
Thanks, applied in 0.05 with tests. Please, if you find any issues in the future, include tests for both pass and fail conditions with your patch. I have supplied three tests - comparing regexes which should match, comparing when they shouldn't, and comparing a regex to an ordinary scalar which is the same as the regex's stringification.