thinker has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with header() method when extending CGI.pm
by derby (Abbot) on Jan 09, 2002 at 18:42 UTC | |
|
Re: Problem with header() method when extending CGI.pm
by Hrunting (Pilgrim) on Jan 09, 2002 at 19:11 UTC | |
|
Re: Problem with header() method when extending CGI.pm
by kwoff (Friar) on Jan 09, 2002 at 23:57 UTC | |
by thinker (Parson) on Jan 10, 2002 at 00:25 UTC |