Stating the obvious perhaps, but as use of objects/methods is optional in Perl
(but not in Java from which you're translating), and
having a code fragment that can be grouped together arises whether or not
you're writing in OO style, the answer Turn the fragment into a method ... could just as well be
Turn the fragment into a subroutine ..., i.e. refactoring in Perl is not limited to object oriented considerations.