dslreports logo
site
 
    All Forums Hot Topics Gallery
spc

spacer




how-to block ads


Search Topic:
share rss forum feed
« Free HostSiteEZ? »
This is a sub-selection from Share code


Kelarch

join:2001-12-23
Lawrenceville, GA
reply to PingPong3

Re: Share code

Thanks for posting. I love to read other peoples code. I get bored staring at my own programming style all the time :). I just finished my first "real" program in Perl, and this is what I used to process the forms it had to handle. It's nothing special. In fact it could probably be written alot better, but I'm no Perl hacker. I also have a bad habit at using non-descriptive variable names which is evident in this snippet.

code:
sub getForm
{
read(STDIN,$data,$ENV{'CONTENT_LENGTH'});
for($loop = 0;$loop != $ENV{'CONTENT_LENGTH'};$loop++)
{
$data =~ s/%2F/\//;
$data =~ s/%3A/:/;
}
@temparray = (split(/&/,$data));
$temp = @temparray;
%temphash = ();
for($loop = 0;$loop != $temp;$loop++)
{
($name,$data) = split(/=/,@temparray[$loop]);
$temphash{$name} = ($data);
}
return %temphash;
}

It was designed to return all the data to a hash. It also only handles forms submitted using POST. Personally I don't think it's well written. It just seems bloated and ineficient. Maybe I'm just too critical of my own code...
--
I'm not paranoid: everyone IS out to get me.