use URI; use URI::QueryParam; my $uri = URI->new($new_url); foreach my $sid_string(qw(sessionid lsessionid jsessionid SID PHPSESSID SessionID BV_SessionID osCsid)){ $uri->query_param_delete($sid_string); } print "$uri";