Loading ...
Sorry, an error occurred while loading the content.

Subroutine

Expand Messages
  • Luiz Fernando de Souza Junior
    Hi, I have a ready form to send a comunicate by email, i don t know who make it. And one o sub is very strange to me, someone can tell what it does? I like to
    Message 1 of 1 , Nov 8, 2000
    • 0 Attachment
      Hi,
      I have a ready form to send a comunicate by email, i don't know who make it.
      And one o sub is very strange to me, someone can tell what it does?
      I like to ask something else:
      in line 1, for what "@_ if @_"?
      in line 22 and 23, what's happen?
       
      1 sub ReadParse {
      2    local (*in) = @_ if @_;
      3    local ($i, $key, $val);
      4
      5    if ( $ENV{'REQUEST_METHOD'} eq "GET") {
      6      $in = $ENV{'QUERY_STRING'};
      7    } elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
      8      read(STDIN,$in,$ENV{CONTENT_LENGTH});
      9    } else {
      10           $in = ( grep( !/^-/, @ARGV )) [0];
      11           $in =~s/\\&/&/g;
      12   }
      13
      14   @in = split(/&/,$in);
      15
      16   foreach $i (0 .. $#in) {
      17     # Convert plus's to spaces
      18     $in[$i] =~s/\+/ /g;
      19
      20     ($key, $val) = split(/=/,$in[$i],2); # splits on the first =.
      21
      22     $key =~s/%(..)/pack("c",hex($1))/ge;
      23     $val =~s/%(..)/pack("c",hex($1))/ge;
      24
      25     $in{$key} .= "\0"if (defined($in{$key}));
      26     $in{$key} .= $val;
      27    }
      28    return length($in);
      29 }
      30
    Your message has been successfully submitted and would be delivered to recipients shortly.