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

Question: In what version of Perl is "our" introduced and supported?

Consider this code:

package Errors; require Exporter; use strict; our @ISA = qw(Exporter); our @Export = qw( error, ff_error, HTMLErrorFormat, ); # ... more stuff...
Which gives me this:
>perl -c Errors.pm Bareword "our" not allowed while "strict subs" in use at Errors.pm lin +e 14. Array found where operator expected at Errors.pm line 14, at end of li +ne (Do you need to predeclare our?) syntax error at Errors.pm line 14, near "our @ISA " Global symbol "@ISA" requires explicit package name at Errors.pm line +14. Bareword "our" not allowed while "strict subs" in use at Errors.pm lin +e 15. Array found where operator expected at Errors.pm line 15, at end of li +ne (Do you need to predeclare our?) Global symbol "@Export" requires explicit package name at Errors.pm li +ne 15.

-------------------------------------
Nothing is too wonderful to be true
-- Michael Faraday

Replies are listed 'Best First'.
Re: Trouble using "our" in Perl 5.005.03
by fglock (Vicar) on Jun 12, 2003 at 18:11 UTC
Re: Trouble using "our" in Perl 5.005.03
by hardburn (Abbot) on Jun 12, 2003 at 18:03 UTC

    I'm not sure exactly when our was introduced, but you can use vars; instead to do the same thing. Example:

    use vars qw(@ISA @Export); @ISA = qw(Exporter); @Export = qw( error, ff_error, HTMLErrorFormat, );

    vars is basically deprecated in favor of our, but it's still there if you need it.

    Update: Forgot to mention that you don't need those commas in your qw() statements. The idea behind qw() is that it splits the list on whitespace, not commas.

    ----
    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

Re: Trouble using "our" in Perl 5.005.03
by arthas (Hermit) on Jun 12, 2003 at 18:18 UTC

    our works only in Perl 5.6.0+. Depending on what you need to do with it, you can try use vars instead.

    Or, even better, upgrade perl. ;-)

    Michele.