Well, I haven't looked too closely, but from the short if/else section, you want to start by making functions, like this
if ($category_id eq "all") {
push @all_matches, SomethingAll(...);
}
elsif ($category_id eq "subj") {
push @all_matches, SomethingSubj(...);
}
which you would later turn into a dispatch table
my %dispatch_table = (
all => \&SomethingAll
subj => \&SomethingSubj
_default => \&SomethingDefault
);
...
my $callback = $dispatch_table{$category_id} || $dispatch_table{_defau
+lt};
push @all_matches, $callback->(...);
OO not required. When deciding which function to call requires something more complicated than a simple string comparison (key lookup), you'll benefit more from using object-oriented-programming.
perl Moose Strategy Design Pattern -> https://secure.wikimedia.org/wikibooks/en/wiki/Computer_Science_Design_Patterns/Strategy#Perl