in reply to Use of 'our' considered harmful

What you are really saying is:

Use of new features considered harmful
You are of course allowed to have any opinion you want, but I strongly disagree. The new features make some things much easier and that is worth the trouble in my opinion.

I think neither the original title nor my rewrite of it really do anything about the real problem you have. I humbly propose the following statement:

Use of ANCIENT PERL considered painful

Perl 5.005_03 is 5 years old.

I'll buy a crate of beer for the first person who can show me some real-world code which absolutely requires our and can't be re-written to use my.

With those unstrict rules, it's easy:

package Acme::Example; use base 'Exporter'; our $VERSION = '1.00'; our @EXPORT_OK = qw(example); sub example { ... }
This cannot be rewritten with my, because then things start to break. It can be rewritten using use vars, but you didn't mention that at all. You owe me a crate of beer :) I'm not the first, but tantarbobus has earned the beer! :)

Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

Replies are listed 'Best First'.
Re^2: Use of 'our' considered harmful
by itub (Priest) on Sep 24, 2004 at 12:50 UTC
    Of course, it only matters if you use strict. I'm not saying you shouldn't use it, but what's stopping you from using it after the variables that really need to be public?

    package Acme::Example; use base 'Exporter'; $VERSION = '1.00'; @EXPORT_OK = qw(example); use strict; sub example { ... }

      Nothing's stoping you. But do you also access those variables before you use strict? :)

      (That is, every mention of a package variable under use strict -- whether a declaration or use -- needs to be fully qualified, or in the scope of an our or a use vars. (Well, mentioning scope when talking about use vars is misleading, since its effect is declarative and not lexical.))