Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Replacing parts of a string

by arturo (Vicar)
on Apr 11, 2003 at 14:52 UTC ( #249901=note: print w/replies, xml ) Need Help??

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://249901]
[LanX]: ah... Denmark is planning to build a wall at the German border!
[LanX]: # Pestis Africana Suum
[erix]: that's an old plan, I think. Isn't there already a danewal (or some such name)?
[marto]: Build with -Wall
[erix]: Danewerk
[LanX]: I seem to remember that the danewall was build by the Frankish empire against the Danes
[erix]: 500 AD thru viking age
[erix]: that would make sense but wikipedia thinks otherwise
[LanX]: oh me was wrong ...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2018-03-22 18:38 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (283 votes). Check out past polls.