L0rdPhi1 has asked for the wisdom of the Perl Monks concerning the following question:
Thanks!sub formatParse { my $buffer = shift; my (%temp, %count, @params); foreach my $pair (split /[&;]/, $buffer) { my ($name, $value) = split /=/, $pair; $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9]{2})/pack("c", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9]{2})/pack("c", hex($1))/eg; push(@params, [$name, $value]); $count{$name}++; } foreach my $key (@params) { $coun{$key->[0]} = 0 unless $coun{$key->[0]}; if ($count{$key->[0]} == 1) { $temp{$key->[0]} = $key->[1]; } else { $temp{$key->[0]}->[$coun{$key->[0]}] = $key->[1]; $coun{$key->[0]}++; } } return %temp; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Better way to do this?
by Beatnik (Parson) on Jun 03, 2002 at 06:45 UTC | |
|
Re: Better way to do this?
by Abigail-II (Bishop) on Jun 03, 2002 at 10:09 UTC | |
by cjf (Parson) on Jun 04, 2002 at 00:42 UTC | |
|
Re: Better way to do this?
by Anonymous Monk on Jun 03, 2002 at 06:48 UTC | |
|