At it's simplest you can get the url using the CGI.pm module:
#!/usr/bin/perl
use CGI;
$query=CGI::new();
$url=$query->self_url;
You could then test $url using if () {} as in your example.
But I'm not sure - are you looking to call different subs based on the query string in the url (ie the part following the '?')?
var string = location.search()
In a cgi program you'll have to identify the part of the url that is located after the questionmark. Following sugarkanes example, you can do like this:
$url =~ \?.*$
This weird looking code isolates the part of the string "$url" that is located between the questionmark and the end of the line (the? is included.)
/claus