Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: How to change the symbol table to wrap a sub in another sub ?

by ikegami (Patriarch)
on Sep 21, 2006 at 18:45 UTC ( [id://574222]=note: print w/replies, xml ) Need Help??


in reply to How to change the symbol table to wrap a sub in another sub ?

Why not just subclass CGI?

If you don't want to do that, then I recommend the following:

# Must appear before "use CGI". BEGIN { require CGI; package CGI; no warnings 'redefine'; my $real_param = \&CGI::param; sub param { if (wantarray) { return map { Encode::decode_utf8($_) } $real_param->(@_); } else { return Encode::decode_utf8($real_param->(@_)); } } }

My version fixes two bugs.

  • My version works when called as a function.
  • My version works correctly when called in list context.

Updated to work in list context.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://574222]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (12)
As of 2024-04-23 14:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found