kwaping has asked for the wisdom of the Perl Monks concerning the following question:
I thought it might be better written as a map, so I came up with this:foreach $key (keys %form_data) { my $temp1=$key; my $temp2=$form_data{$key}; $temp1=~s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg; $temp2=~s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg; $form_data.=$temp1.'='.$temp2.'&'; } $form_data=~s/\&$//;
$form_data = join('&', map { s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1) +)/seg; $form_data{$_} =~ s/([^A-Za-z0-9])/sprintf +("%%%02X", ord($1))/seg; "$_=$form_data{$_}"; } sort keys %form_data);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: map { ; ; ; } @array
by jeffa (Bishop) on Oct 21, 2005 at 18:36 UTC | |
by halley (Prior) on Oct 21, 2005 at 19:07 UTC | |
by Anonymous Monk on Oct 21, 2005 at 20:26 UTC | |
by Perl Mouse (Chaplain) on Oct 24, 2005 at 11:16 UTC | |
by Roy Johnson (Monsignor) on Oct 21, 2005 at 18:55 UTC | |
|
Re: map { ; ; ; } @array
by ikegami (Patriarch) on Oct 21, 2005 at 19:10 UTC | |
by kwaping (Priest) on Oct 21, 2005 at 19:16 UTC | |
|
Re: map { ; ; ; } @array
by ikegami (Patriarch) on Oct 21, 2005 at 18:53 UTC | |
|
Re: map { ; ; ; } @array
by rvosa (Curate) on Oct 21, 2005 at 19:35 UTC | |
|
Re: map { ; ; ; } @array
by kwaping (Priest) on Oct 21, 2005 at 19:05 UTC |