If these are utilityish methods that don't actually need a real blessed object, then:
package Foo::Utils { sub frobnicate { shift; # ignore invocant print "frobnicating!\n"; } } ...; # some time later my $utils = "Foo::Utils"; # no need for a constructor ...; # some time later $utils->frobincate; # call as a class method
That said, writing a constructor isn't hard:
package Foo::Utils { sub new { bless [], shift } sub frobnicate { shift; # ignore invocant print "frobnicating!\n"; } }
Or even easier:
package Foo::Utils { use Moo; sub frobnicate { shift; # ignore invocant print "frobnicating!\n"; } }
In reply to Re^2: When to Use Object Oriented approach in Perl? (RFC)
by tobyink
in thread When to Use Object Oriented approach in Perl? (RFC)
by thanos1983
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |