What are good alternatives to attributes and builders, and how do they compare?

Explore effective alternatives to attributes and builders in Perl, such as Hashes and Object-Oriented approaches, and compare their benefits for streamlined code structure.
Perl alternatives, attributes, builders, Perl hashes, Object-Oriented Perl

# Example of using Hashes as an alternative to Attributes

# Define a package
package Person;
use strict;
use warnings;

sub new {
    my ($class, %args) = @_;
    return bless \%args, $class; # Store attributes in a hash reference
}

sub get_name {
    my ($self) = @_;
    return $self->{name}; # Accessing the name from the hash
}

# Create a new Person object
my $person = Person->new(name => 'Alice', age => 30);

# Retrieve the name
print $person->get_name(); # Outputs 'Alice'
    

Perl alternatives attributes builders Perl hashes Object-Oriented Perl