Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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


In reply to Re: Replacing parts of a string by tachyon
in thread Replacing parts of a string by spiderbo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-19 06:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found