> > I've been getting frustrated by the mandatory warning created by 'use
> > constant' under mod_perl, caused by constant subroutines being redefined
> > when imported. In particular, with Archive::Zip this was adding hundreds
of
> > lines to my log every restart.
>
> what version of Perl are you using?
> the mandatory constant-sub-redefined warning went away in 5.004_66:
>
Sorry--you're quite right... it's not a mandatory warning at all any more. I
run all my scripts when developing under -w, so I still get the warning.

I think it would be useful to specifically check that the sub is not already
defined in the caller's namespace:
if (!(defined &{"${pkg}::$name"})) {
    <import the const sub>
}

This works fine for me... without it, it's very hard to notice many warnings
which provide useful diagnostic information. Worse still, some people may
just turn off -w altogether to avoid their logs filling up.

Reply via email to