in reply to Replacing parts of a string

OK, this will not enhance your regex-fu, and it may not be the most efficient (in terms of runtime resource allocation) solution, but it's a dead easy one to use, and very efficient in terms of programmer-hours spent on the problem. Following up on jasonk's suggestion, you don't even need it to be the case that the script doing the parsing is Simply feed the query string to a object and let it do the parsing for you:

#!/usr/bin/perl + use CGI; use strict; use warnings; # note you want everything after the ? my $querystring='loginid=102138&month=04&year=2003&student_id=&user_ty +pe=TUTOR&CalendarName=102138Academic&framename=top.index_main&session +_number=618280744437303'; + my $q = CGI->new($querystring); + foreach my $p ( $q->param() ) { print "Parameter $p : " . $q->param($p) . "\n"; }

If not P, what? Q maybe?
"Sidney Morgenbesser"

Replies are listed 'Best First'.
Re: Re: Replacing parts of a string
by aquarium (Curate) on Apr 12, 2003 at 10:14 UTC
    ditto...use or similar--or be at the peril of code injection inside URLs. You should also use taint...and check (with a simple regex) that the parameters you receive are alphanumeric only (no quotes etc.) Chris