#!/usr/bin/perl use strict; use warnings; use CGI; my $q = CGI->new(); sub url_query_string { my ($q) = @_; # get the names of all URL parameters my @params = grep { length($_) } $q->url_param; return (@params > 0 ? '?' : '').join('&',map { # $q->url_param returns unescaped values so we have to escape them # again sprintf("%s=%s",$_,CGI::escape($q->url_param($_))) } @params); } print $q->header('text/plain'), $q->url(-absolute => 1).url_query_string($q),"\n";