It sounds like this might be a performance critical part of your application. In this case, you may want to consider writing a C extension method to do the comparison.
Perl provides the XS extension mechanism which makes this reasonably straightforward.