In Perl, using CGI.pm url() will be the NAME of the domain and scirpt:
http://www.mydomain.com/index.cgi?page=something&whatever=1
url() would be: http://www.mydomain.com/index.cgi
How does PHP do this?
You would need to concatinate two predefined variables to get that. Give this a try.
<?php print($_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']); ?>