perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gerald Richter" <rich...@ecos.de>
Subject RE: Dynamic URI query strings
Date Wed, 07 Jun 2000 14:08:06 GMT
> 
> > Why don't you simply append to the string? Am I missing something?
> 
> Because that would end up with something like:
> /investment/detail.epl?code=FOO&display=WOTSIT&it=BAR&code=007&new=YES
> I don't want 'code' twice!
> 
Aah, I see...


Then I would use a regex and a hash:

my $uriprefix = '/investment/detail.epl?code=FOO&display=WOTSIT&it=BAR';
my @parts     = split (/\?/, $uriprefix) ;
my %parms     = split (/\&|=/, $parts[1]) ;
$parms{'code'} = '007' ;
$parms{'new'} = 'YES' ;
$uriprefix = parts[0] . join ('&', %parms) ;
print $uriprefix, "\n";

It's not much shorter, but faster anyway

Gerald



Mime
View raw message