in reply to Re^5: Unclear about 'our'
in thread Unclear about 'our'

I agree with your suggestion to make the module OO -- which means it's time to bite the bullet and learn how to write OO Perl. :-) I know there are various CPAN modules that support it; do you have a recommendation?

Replies are listed 'Best First'.
Re^7: Unclear about 'our'
by haukex (Archbishop) on Dec 28, 2022 at 17:36 UTC

    Perl OO, at its simplest, actually doesn't involve that much boilerplate so that IMHO it's worth it to learn that - see my example below as well as perlootut and perlmod (Update: and perlobj). But when I do use a module, I typically go for Moo.

    package Foo; use warnings; use strict; sub new { my ($class, $bar) = @_; my $self = { bar => $bar }; return bless $self, $class; } sub foo { my $self = shift; print "Bar=", $self->{bar}, "\n"; } 1;
Re^7: Unclear about 'our'
by karlgoethebier (Abbot) on Dec 30, 2022 at 18:09 UTC