Here is a quick reminder. When you have a class/object that only has a single method.

1
2
3
4
5
6
7
8
9
my $obj = Class->new(
    arg1 => "whatever",
    arg2 => 10,
);

my $result = $obj->one_method(
    arg3 => [],
    arg4 => {},
);

then just make a single function out of it.

1
2
3
4
5
6
my $result = one_method(
    arg1 => "whatever",
    arg2 => 10,
    arg3 => [],
    arg4 => {},
);

this also works with multiple methods, but with just a single method it defenitely should just be a single function. Also consider that Perl has great ability for passing arguments. For example you also can do.

1
2
3
4
5
6
7
8
my %default = (
    arg1 => "whatever",
    arg2 => 10,
    arg3 => [],
);

my $res1 = one_method(%default, arg4 => { ... });
my $res2 = one_method(%default, arg4 => { ... });

Related

In that example, the hash %default basically acts as your object.