$str = "calendarview.pl?loginid=102138&month=04&year=2003&student_id=&user_type=TUTOR&CalendarName=102138Academic&framename=top.index_main&session_number=618280744437303"; # first amputate the calendarview.pl? bit $str =~ s/^[^\?]+\?//; # use CGI.pm to parse the string by creating a CGI instance from it use CGI; $q = CGI->new($str); # modify whatever you want, lets delete what you specified $q->delete('CalendarName'); $q->delete('month'); $q->delete('year'); # and modify loginid just for laughs $q->param( 'loginid', 'haxor' ); # add a new param if you want $q->param('i am a new one', 'this is my value' ); # write out the new query string (default is to use ; not & so we do:) $CGI::USE_PARAM_SEMICOLONS = 0; print $q->query_string(); __DATA__ loginid=haxor&student_id=&user_type=TUTOR&framename=top.index_main&session_number=618280744437303&i%20am%20a%20new%20one=this%20is%20my%20value