http://www.perlmonks.org?node_id=25570

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This one has me baffled. I am getting the following result from using $cgi_obj->escape("some_value"): CGI=HASH(0x1d7820) This is NOT what anyone would normally expect from a call to escape, and unescape produces similar output. My key difference is that I'm on a Sun machine running SunOS 5.6 (it appears from running 'uname') whereas I've never had this problem on linux or windows. Any body care to comment? Thanks. Mike

Originally posted as a Categorized Question.

  • Comment on My parameters can't escape from the Sun...

Replies are listed 'Best First'.
Re: My parameters can't escape from the Sun...
by davorg (Chancellor) on Aug 02, 2000 at 00:30 UTC

    I think this is a problem with older versions of CGI.pm. In older versions on the module (and I can't remember when it changed) the escape subroutine didn't have a OO interface, so it expected its first parameter to be the string to be escaped.

    By calling it with an OO interface, as you have, you give it the CGI object as the first parameter. escape tries to URL encode that object and returned the URL encoded version. When you print out the return code, you the string representation of the object, which is the type and reference - hence the output you see.

    Solutions: 1/ Get a more recent version of CGI.pm. 2/ Call escape using the functional interface like this:

    $escaped = escape('some text');
Re: My parameters can't escape from the Sun...
by autark (Friar) on Aug 02, 2000 at 00:26 UTC
    Maybe you are trying to interpolate method calls in strings? Unfortunatly, function- and method calls will not interpolate in strings. So you might try something like this instead: print "Got: ", $cgi->escape("some_value"), "\n"; Well, you can do something like the following, but I don't think it's pretty: print qq(Got: @{[ $cgi->escape("some_value") ]}\n); Autark