Use CGI.pm to do it for you thusly (this is very robust):
$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&ses
+sion_number=618280744437303&i%20am%20a%20new%20one=this%20is%20my%20v
+alue
You will be hard pressed to break this solution - it is much better than using regexes from a robustness point of view.
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|