in reply to "use strict;" woes

Another bug which I don't think anyone has caught here is ...
print header, "test";
What is 'header'?

Update: oh, yeah, CGI.pm. Oops. In my defence, I don't use CGI.pm to generate HTML :-)

Replies are listed 'Best First'.
Re: Re: "use strict;" woes
by Ovid (Cardinal) on Oct 14, 2003 at 19:08 UTC

    header is not a bug; it's one of the functions exported by CGI when using ":all" or ":standard". If you don't export it, you either call it with a fully qualified name or as a method.

    use CGI; print CGI::header(); # or my $q = CGI->new; print $q->header;

    Cheers,
    Ovid

    New address of my CGI Course.

Re: Re: "use strict;" woes
by hardburn (Abbot) on Oct 14, 2003 at 19:08 UTC

    That one is OK--header() is imported with use CGI qw(:all);.

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    Note: All code is untested, unless otherwise stated

2Re: "use strict;" woes
by jeffa (Bishop) on Oct 14, 2003 at 21:52 UTC
    Unless you are using mod_perl, i really see no excuse to not use CGI.pm to generate an HTML header. It's just too easy:
    use CGI qw(header); # only loads the header method print header();
    Regardless of what you think about CGI.pm and it's other HTML generation methods (and i always say "right tool for the right job" here), i still recommend you use the header method.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)