Hi Fellow Monks,
We have a small team of 3 perl programmers in our organization and when we were thought perl (around 2 years back) we did not know of CGI.pm so we used a subroutine called readparse (code below) and we have never used use Strict...we have continued with that habit and now i am trying to develop a culture of good coding practice but the programmers feel that when the following code has been working and they are used to it and can develop the code at a fast pace(after submitting from a form the variables are created on the fly they do not have to declare each variable and assign values from the form)..i need some thoughts on this
Thanks
readparse(*input);
my $strTemp;
foreach $strTemp(keys %input) {
${($strTemp)} = $input{$strTemp};
}
sub readparse {
local (*in) = @_ if @_;
local ($i, $loc, $key, $val);
if ($ENV{'REQUEST_METHOD'} eq "GET") {
$in = $ENV{'QUERY_STRING'};
}
elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN,$in,$ENV{'CONTENT_LENGTH'});
}
@in=split(/&/,$in);
foreach $i (0..$#in) {
$in[$i]=~ s/\+/ /g;
($key, $val) = split(/=/,$in[$i],2);
$key =~ s/%(..)/pack("c",hex($1))/ge;
$val =~ s/%(..)/pack("c",hex($1))/ge;
$in{$key} .= "\0" if (defined($in{$key}));
$in{$key} .= $val;
}
return 1;
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.