in reply to Re^3: CGI::Application - Which is the proper way of handling and outputting utf8
in thread CGI::Application - Which is the proper way of handling and outputting utf8

Is there a way to have imports automatically forwarded to CGI?

For example with:

use CGI::as_utf8 qw/-no_xhtml/;
-no_xhtml is not forwarded to CGI!

  • Comment on Re^4: CGI::Application - Which is the proper way of handling and outputting utf8

Replies are listed 'Best First'.
Re^5: CGI::Application - Which is the proper way of handling and outputting utf8
by davebaker (Pilgrim) on Oct 29, 2020 at 20:52 UTC

    I think, with the current version of CGI.pm, you could get the -no_xhtml pragma into CGI.pm by putting this into your application module. (It overrides the cgiapp_get_query method in the CGI::Application parent.)

    sub cgiapp_get_query { my $self = shift; use CGI ('-no_xhmtml'); my $q = CGI->new; return $q; }

    The current version of CGI.pm doesn't use that particular pragma, but the code would work if some other pragma were desired, such as -utf8.

      No. Make a subclass.

        Why?

        And a code example of such a subclass, please.

Re^5: CGI::Application - Which is the proper way of handling and outputting utf8
by ikegami (Patriarch) on Dec 15, 2010 at 23:52 UTC
    I think the following will do the trick.
    sub import { shift; unshift(@_, 'CGI'); goto &CGI::import; }