False Hopes.

No luck yet. I thought I had figured it out. Not yet.

In spite of correcting the spelling of the variable from 'formdata' to
'formData',
the hash does not get initialized.

I have hit the wall pretty hard.

Thanks,

Samy Rengasamy.

-----Original Message-----
From: Rengasamy, Samy 
Sent: Thursday, August 08, 2002 3:10 PM
To: Rengasamy, Samy; [EMAIL PROTECTED]
Subject: RE: Hash Initialization Problem


Sorry everybody.

Ignore this problem Please. 
I had misspelled the variable name at initialization.

Thanks,

Samy Rengasamy.

-----Original Message-----
From: Rengasamy, Samy 
Sent: Thursday, August 08, 2002 3:04 PM
To: [EMAIL PROTECTED]
Subject: Hash Initialization Problem


I am struck with this issue for last couple of hours.

I pass the HTTP::Request->content() data for parsing to a function
parseData.
This function gets called several times inside a loop.

In spite of initializing the hash variable 'formData', it seems to be
retaining
the key-value pairs from previous calls.

How do I escape from this situation.

Thanks,

Samy Rengasamy.


sub parseData($) {
    my $formDataString = shift;
    undef %formdata;
    my %formdata = ();

    @pairs = split(/[&;]/, $formDataString);            # split on "&" and
";"

    foreach $pair (@pairs) {                            # one at a time
      ($key, $value) = split (/=/, $pair);              # split on "="
      $key =~ tr/+/ /;                                  # trans "+" to space
      $key =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;  # Hex to
ASCII

      $value =~ tr/+/ /;
      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
      $value =~ s/<!--(.|\n)*-->//g;                    # no server side
includes
 
      $exp = $_[0];
      $exp2 = $exp % 2;                                 # rightmost bit
      if ($value eq '') {
        if ($exp2 == 1) { $value = $ENV{$key}; }
      }
      $exp = int($exp / 2);                             # strip rightmost
bit
      $exp2 = $exp % 2; 
      if ($value eq '') {
        if ($exp2 == 1) { $value = $date_time{$key}; }
      }

      if ($panelType eq "ACTION") {
         if ($key =~ /D-\d\d-\d\d-\d\d/m) {
            print "httpd::parseData --> names : $key <==> $value\n";
            $formData{$key} = $value;                 # Only the D Fields
and are required
         }
      } 
      else {
         if ($key eq "userid" || $key eq "password") {
            print "httpd::parseData --> names : $key <==> $value\n";
            $formData{$key} = $value;                 # Only the D Fields
and are required
         }
      }

    print "httpd::parseData --> formData : ", %formData, "\n";

    return %formData;

}

Reply via email to