$next_url = "http://blabla.com/cgi/script.cgi?"; $next_url .= "city=" . $city if($city); ... $next_url =~ s/\?$//; # remove question mark if no parameters added to next_url