helick has asked for the wisdom of the Perl Monks concerning the following question:

Hello everyone,

I have inherited a project (for a prof.) that is giving me much grief. Mostly because I am new at Perl.

What happens is as follows:
SessionTable.pm has the snipped bellow.
package SessionTable; use BasicTable; use Digest::MD5; use strict qw(@ISA); @ISA = qw(BasicTable);

But I get the following error message on the browser screen:
Error message:
Premature end of script headers: ate.pl
Error 5000

ate.pl is the main script that we use, and it calls for the package mentioned above.

The message on apache's error_log is:
[Wed Sep 10 13:58:58 2003] [error] [client ip_number] Unknown 'strict' tag(s) '@ISA' at /survey/cgi-bin/SessionTable.pm line 6, referer: http://myhost/cgi-bin/ate.pl

Keep in mind that everything works fine on the box running apache1 (RH7.3). This new box is running RH9.0 with RH's distributed apache.
Am I missing anything?

Please let me know, any help is appreciated.
-helio

janitored by ybiC: Balanced <code> tags around code snippet, as per Monastery convention, replaced literal [ and ] with &#091 and &#093 to avoid conversion to PM-style links

20030911 Edit by jeffa: Changed title from 'works on apache 1, but not 2... '

Replies are listed 'Best First'.
Re: apache2 conflicts with strict declaration
by perrin (Chancellor) on Sep 10, 2003 at 18:22 UTC
    RH 7.3 comes with Perl 5.6, while RH 9 comes with Perl 5.8. Maybe the older Perl did something with this call to strict that actually worked. It looks like a bug to me, which may be why it no longer works.

    Correct usage would be this:

    use strict; use vars qw(@ISA);
    Youl could use "our" instead of "use vars", but I think that's silly and it doesn't work on Perls older than 5.6.
Re: apache2 conflicts with strict declaration
by liz (Monsignor) on Sep 11, 2003 at 00:22 UTC
    I guess I'm sort of responsible for this. Before 5.8.1, any string following use strict was allowed. After spending about a day trying to find out why I was still getting redefine warnings in my code, I found out that in fact instead of: no warnings 'redefine' I had put no strict 'redefine' which somehow made sense in my mind. Except that it didn't silence the redefine warnings. But didn't give me any error either.

    I decided to submit a patch to p5p that would warn like this:

    $ perl5.8.1 -M-strict=redefine -e 1 Unknown 'strict' tag(s) 'redefine' at -e line 0
    and the patch got accepted. Even though 5.8.1 is not out officially, I think the perl that is in RH9.0 is sufficiently like 5.8.1 to have this patch applied.

    As to the fact that it works fine in RH7.3. Well maybe, but technically the line was wrong: @ISA got defined as a side effect. Observe:

    $ perl5.8.0 -Mstrict -e "@ISA = ()" Global symbol "@ISA" requires explicit package name at -e line 1. Execution of -e aborted due to compilation errors. $ perl5.8.0 -Mstrict=@ISA -e "@ISA = ()"
    As to why it got defined originally as a side-effect, I don't know yet. The code in strict.pm is pretty straightforward so there must be som magic going on. I guess I am too tired now to see exactly why it's getting defined. I'll sleep on it and update tomorrow.

    Liz

      Ok, a night's sleep definitely gives you some perspective. So why does:
      use strict qw(@ISA);
      seem to do the right thing before 5.8.1? Well, it's very easy. If you do that in Perl's before 5.8.1, strict is not enforced at all in your program!.

      Observe:

      $ perl5.8.1 -Mstrict=@ISA -e '$foo = 1' Unknown 'strict' tag(s) '@ISA' at -e line 0 BEGIN failed--compilation aborted.
      now fails at attempting to use "@ISA" as a keyword. Older versions of Perl, allowed this:
      $ perl5.8.0 -Mstrict=@ISA -e '$foo = 1'
      In other words, the "$foo" not being declared, does not give an error. It should have said:
      $ perl5.8.0 -Mstrict -e '$foo = 1' Global symbol "$foo" requires explicit package name at -e line 1. Execution of -e aborted due to compilation errors.

      So, the statement "that everything works fine" may well be true, as you can make perfectly running programs without using strict. But had the original developer made errors in the naming of variables, you wouldn't have known about it because of the lack stricture actually being applied.

      Hope this clears up this little riddle.

      Liz

        Looking at the source for strict.pm under 5.8.1 RC4, this seems weird. I guess they just moved some checks into use? Seems strange they they didn't just check for them in strict.pm.

        antirice    
        The first rule of Perl club is - use Perl
        The
        ith rule of Perl club is - follow rule i - 1 for i > 1