Dear Monks,

I am getting some strange errors from URI::Escape and assume that I must be something stupid. I am getting the following errors in Apache's log file:

Use of uninitialized value in subroutine entry at /usr/local/lib/perl5 +/site_perl/5.6.1/URI/Escape.pm line 140. [Fri Apr 12 14:16:18 2002] [error] Can't use string ("") as a subrouti +ne ref while "strict refs" in use at /usr/local/lib/perl5/site_perl/5 +.6.1/URI/Escape.pm line 140. Possible unintended interpolation of @aol in string at (eval 187) line + 1. [Fri Apr 12 14:28:22 2002] [error] uri_escape: Global symbol "@aol" re +quires explicit package name at (eval 187) line 1. at /usr/local/apache/perl/some.cgi line 179 Possible unintended interpolation of @aol in string at (eval 185) line + 1.
The "@aol" appears nowhere in my code - it is part of an email address that some user is submitting. My code compiles and runs fine and uses both warnings and use strict - it works most of the time, but these errors sometimes occur.
Here are the relevant sections of my code which use URI::Escape (the param call is to Apache::Request)
#a bunch of lines like the following to get POST'd data: my $email = uri_escape($apr->param('email' ))||''; my $customerid = uri_escape($apr->param('customerID'))||''; #then get a ref to a hash of all posted values #it's redundant, i know, but it serves a purpose my $values = $apr->param; #later, to construct a redir, this hack: my $base_url = "http://foo.com/somecgi?"; my $middle = join('&', map { $_ . "=" .uri_escape($values->{$_}) } keys %$values ); my $tail = "&FilePath=$cleanfilename&transfer_source=http"; my $redir = $base . $middle . $tail; # sub to construct a log string or submitted info # anonymous to avoid warnings under mod_perl my $err_log = sub { my $up = shift; my @vars = ( $up, $clientb, $clientbv, $clientos, $trckingnum, $customerid, $xferid, $cgi,$customerid, $contactname, $email,$phone,'htttp' ); my $string = join(',', map {"\"" . $_ . "\""} map {uri_unescape($_)} @vars ); $string .= "\012"; return $string; };
It seems that somehow the strings that are being passed to URI::Escape, which eval's a regex in an anonymous subroutine, are being seen as code, specifically the "@" in email addresses, and causing an error - but only some of the time.

Environment is Apache 1.3.24 / mod_perl 1.26
Apache::Request 1.0
URI::Escape 1.18

Thanks for your help.

Edit kudra, 2002-04-16 Added readmore


In reply to incorrect use of URI::Escape? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.