Hello Monks,

I have been trying to 'extend' CGI.pm, to customise it to a site I am working on. (btw. Are there many other monks who approach this problem in this way?)

While most of it does what I want, when I call the header() method, my instance does not behave as I expect.

Here is a simple example of what is going wrong. My module looks like

#!/usr/bin/perl -w package IsaCGI; use strict; use CGI; use vars qw(@ISA); @ISA=qw(CGI); sub new{ my $this={}; bless $this,__PACKAGE__; $this->SUPER::new({}); return $this; } sub my_method{ return "hello from isa_cgi\n"; } 1;

I am using the following code to test the module

#!/usr/bin/perl -w use strict; use IsaCGI; use diagnostics; my $q=new IsaCGI; print $q->header; print $q->start_html; print $q->my_method;

when I call the header() method, it prints

Use of uninitialized value at (eval 4) line 28 (#1) (W) An undefined value was used as if it were already defined. It + was interpreted as a "" or a 0, but maybe it was a mistake. To suppre +ss this warning assign an initial value to your variables. Content-Type: text/html; charset=

whereas, if I change use IsaCGI and new IsaCGI to use CGIand new CGI I get

Content-Type: text/html; charset=ISO-8859-1

Can someone enlighten me as to why this is happening? Where has the charset info gone?

Thank you

thinker

In reply to Problem with header() method when extending CGI.pm by thinker

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.