http://www.perlmonks.org?node_id=840156

Perobl has asked for the wisdom of the Perl Monks concerning the following question:

I have been asked to update a script that I did not write. The script is for form processing and the section I'm sharing is basically used to evaluate user data submitted as key-value pairs. I'm having trouble seeing any tangible purpose in four lines of code below (where $value is evaluated):
read (STDIN, $temp, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $temp); foreach $item(@pairs) { ($key, $value) = split(/=/, $item, 2); $value =~ tr/+/ /; $value =~ s/%(..)/pack("c", hex($1))/ge; $value =~ s/\t/ /g; $value =~ s/\0//g; }
I understand what each line does ... for example ...
$value =~ tr/+/ /;
performs transliteration on $value and thus translates characters like !, @, #, etc. to their hex equivalents ... that is, # becomes %23.
$value =~ s/%(..)/pack("c", hex($1))/ge;
The line above then takes the two "hex" digits that make up the string and packs them into their hex equivalent.
$value =~ s/\t/ /g;
This code removes tabs?
$value =~ s/\0//g;
And this code removes nulls? I'm missing the point of these four lines of code used together. It doesn't seem like they're really protecting anything??? Am I missing something? Thanks for your help!