CGI parse and a simple question

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I just throw this out.

map {my($k,$v)=split/=/;$v=~tr/+/ /;
$v=~s/%(..)/pack("C",hex($1))/eg;$="$v"} split/&/,$ENV;


Question is, is there a better way to do multiple substitution? For example,
instead of several lines like this,

$v =~ tr/+/ /;
$v =~ s/%(..)/pack("C",hex($1))/eg;
$v =~ s/some/other/;

one line, where $v appears only once?


Re: CGI parse and a simple question

Quoted text here. Click to load it

It's possible to combine both kinds of translation,

| [rw@doppelsaurus]~#perl -de 0
| Loading DB routines from version 1.33
| Editor support available.
| Enter h or `h h' for help, or `man perldebug' for more help.
| main::(-e:1):   0
|   DB<1> $v = 'bla%20fasel+13'
|   DB<2> $v =~ s/(\+|%(..))/$+ eq '+' ? ' ' : pack('C', hex($2))/ge
|   DB<3> p $v
| bla fasel 13

however, whether or not this can be regarded as an improvement is very
much debatable (I'd certainly prefer the simpler, two-statement

Site Timeline