I haven't tried it but wouldn't URI and it canonical and eq methods work for you?
Update: Looks like URI will not normalize query params. Something like this should work (note, I did not check all cases - feel free to fix!)
!/usr/bin/perl -wd
use URI;
my $u1 = URI->new("http://www.perl.com/cgi-bin/script.cgi?a=b&c=d");
my $u2 = URI->new("http://www.perl.com/cgi-bin/script.cgi?c=d&a=b");
my $u1c = $u1->canonical;
my $u2c = $u2->canonical;
if( urlsEqual( $u1c, $u2c ) ) {
print "equal\n";
} else {
print "not equal\n";
}
sub urlsEqual {
my( $u1, $u2 ) = @_;
my( $q1, $q2 );
# First try URI eq
return 1
if( $u1->eq( $u2 ) );
# nope ... adjust query
$q1 = $u1->query();
$q2 = $u2->query();
$q1 = join( '&', sort( split( /[&;]/, $q1 ) ) )
if $q1;
$q2 = join( '&', sort( split( /[&;]/, $q2 ) ) )
if $q2;
$u1->query( $q1 );
$u2->query( $q2 );
return $u1->eq( $u2 );
}