in reply to apache2 conflicts with strict declaration

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

Replies are listed 'Best First'.
no strict with 'use strict qw(@ISA)'
by liz (Monsignor) on Sep 11, 2003 at 08:06 UTC
    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

        The latest 5.8.1 snapshot has in strict.pm:
        my %bitmask = ( refs => 0x00000002, subs => 0x00000200, vars => 0x00000400 ); sub bits { my $bits = 0; my @wrong; foreach my $s (@_) { push @wrong, $s unless exists $bitmask{$s}; $bits |= $bitmask{$s} || 0; } if (@wrong) { require Carp; Carp::croak("Unknown 'strict' tag(s) '@wrong'"); } $bits; }

        which clearly shows that it is just inside the "strict" module to me.

        I believe it was patch 17869. From Changes:

        [ 17869] Subject: [perl #17061] no strict 'garbage' From: Elizabeth Mattijsen (via RT) <perlbug@perl.org> Date: 6 Sep 2002 19:31:02 -0000 Message-Id: <rt-17061-36808.6.19994322284541@bugs6.perl.org> Date: Sat, 07 Sep 2002 13:40:22 +0200 Message-Id: <4.2.0.58.20020907133846.02476d40@mickey.dijkmat.nl>

        Liz