Package::New(3pm)

πŸ“¦
version 0.10 Β· 6 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– Package::New πŸ’–

okay so bestie, welcome to Package::New β€” it's a Perl manual page (3pm, so you KNOW it's a library situation) and honestly? it's giving simple base package from which to inherit. that's the whole NAME, that's the whole vibe. it's a lil guy you inherit from. slay. πŸŽ€


✨ SYNOPSIS ✨

package My::Package;
use base qw{Package::New}; #provides new and initialize

like. that's it. two lines and you have a constructor. no cap, #provides new and initialize is literally in the comment and it's literally true. πŸ’…


🌸 DESCRIPTION 🌸

so Package::New gives you a consistent constructor for objects. that's the job. that's the whole job.

and the author is so real for this: "I find that I always need these two methods in every package that I build." every single one. every time. and they plan to use this package as the base for all of their CPAN packages. main character energy honestly. πŸ‘‘


πŸ¦‹ RECOMMENDATIONS πŸ¦‹

πŸ’œ Sane defaults

please please PLEASE have a sane default for all your object properties. it's the respectful thing to do. the author recommends code like this:

sub myproperty {
  my $self=shift;
  $self->{"myproperty"}=shift if @_;
  $self->{"myproperty"}="Default Value" unless defined $self->{"myproperty"};
  return $self->{"myproperty"};
}

look at it. the setter, the default, the getter, all in one lil bundle. iconic. ✨

πŸ’œ use strict and warnings

always use strict, warnings and our version. always. no exceptions. this is not a drill. 🚨

package My::Package;
use base qw{Package::New};
use strict;
use warnings;
our $VERSION='0.01';

πŸ’œ Lazy Load where you can

Lazy Loading? when you can? do it. the author recommends it:

sub mymethod {
  my $self=shift;
  $self->load unless $self->loaded;
  return $self->{"mymethod"};
}

don't do the work until somebody actually asks for it. that's the whole philosophy. that's self-care. 🧚


🌈 USAGE 🌈

(this section is just vibes and a heading, bestie, there's no prose here β€” it flows straight into CONSTRUCTOR 🫢)

πŸ‘‘ CONSTRUCTOR πŸ‘‘

🌟 new

my $obj = Package::New->new(key=>$value, ...);

that's the constructor! it takes a list of key=>$value pairs and hands you back an object. mwah. πŸ’‹

🌟 initialize

you can override this method in your package if you need to do something after construction. but honestly? lazy loading may be a better option. the author is just saying. 🀷


πŸ’€ BUGS πŸ’€

log on RT and contact the author. that's it. that's the whole bug policy. not me reading that and respecting the efficiency fr fr.


🫢 SUPPORT 🫢

DavisNetworks.com provides support services for all Perl applications including this package. so if you're stuck, you know where to go. πŸŽ€


⭐ AUTHOR ⭐

Michael R. Davis
CPAN ID: MRDVT
DavisNetworks.com
http://www.DavisNetworks.com/

give it up for Michael. CPAN ID MRDVT. legend behavior. πŸ‘


this program is free software licensed under the...

The BSD License

the full text of the license can be found in the LICENSE file included with this module. go read it, bestie, it's right there. πŸ“„


πŸ”₯ SEE ALSO πŸ”₯

πŸ“ Building Blocks

base, parent

πŸ“ Other Light Weight Base Objects Similar to Package::New

Package::Base, Class::Base, Class::Easy, Object::Tiny, Badger::Base

πŸ“ Heavy Base Objects - Drink the Kool-Aid

VSO, Class::Accessor::Fast, Class::Accessor, Moose, (as well as Moose-alikes Moo, Mouse), Class::MethodMaker, Class::Meta

πŸ“ Even more

Spiffy, mixin, SUPER, Class::Trait, Class::C3, Moose::Role


ok that's the whole page bestie, you ate that πŸ’– now go inherit responsibly πŸ¦‹

and just so we're keeping the receipts: this was perl v5.40.0, dated 2025-01-12, and yes, it's Package::New(3pm). periodt. βœ¨πŸ’…πŸŒΈ

πŸ“¦ where this page comes from