in reply to Re: Strange @ appearance
in thread Strange @ appearance

Thanks 4 responding. Yes, I notice I put that $subject on the wrong line - it isnt in my actual code, just a typo. As for having '@' chars in the input, I don't know. The input is actually POSTed from a web page. I have decoded it like so:
# Get POSTED info and stick it in $post_info. read (STDIN, $post_info, $ENV {'CONTENT_LENGTH'} ); # split off fields and put them in @InfoArray @InfoArray = split(/&/, $post_info); # Remove variable= part and translate data into real chars for ($n = 0; @InfoArray[$n]; $n++) { chomp; # remove newline ($dummy, $temp) = split (/=/, @InfoArray[$n]); $temp =~ tr/+/ /; $temp =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; @InfoArray [$n] = $temp; }
Does anyone see something dodgy with that little lot? Also, yes, it may be a null character, but I have chomped and choped the last line of text, and even done a 'get rid of crap' command  $article =~ s/\ 0//g;, all to no avail. Sheesh, It's gonna take me a while to get used to PERL. It's very powerful and, if you know it, quick, but it's so untidy! Im a Java man you see...

Replies are listed 'Best First'.
Re: Re: Re: Strange @ appearance
by Anonymous Monk on Jul 29, 2001 at 19:14 UTC
    Yikes, don't try and implement CGI.pm yourself. See here for more info.

    Your loop is a little "dodgy", using array slices and such. Also, the chomp() is chomping $_, which means nothing in the context you gave it, since $_ is being set to the array index.

    If you end up not using CGI.pm (ack), rewrite the loop so that chomp actually does something.

    # iterate over the split # placing each element in $_ along the way my @InfoArray; for (split(/&/, $post_info)) { chomp; # remove newline ($dummy, $temp) = split (/=/, $_); $temp =~ tr/+/ /; # ack, urldecoding in a regex ? $temp =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; push(@InfoArray,$temp); }
    But do please try Cgi.pm...it's well equipped to pull out the form values, do the (un)encoding of urls, etc.