in reply to Refactoring Perl #1 - Extract Method

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.
  • Comment on Re: Refactoring Perl 1 - Extract Method

Replies are listed 'Best First'.
Re^2: Refactoring Perl 1 - Extract Method
by agianni (Hermit) on Jun 25, 2007 at 03:50 UTC

    Absolutely. Many of Fowler's refactoring patterns are specific to OO design, but there are plenty of them that are more generally applicable to most subroutine-driven, imperative programming language. I will try to keep that differentiation in mind as I review future patterns.

    perl -e 'split//,q{john hurl, pest caretaker}and(map{print @_[$_]}(joi +n(q{},map{sprintf(qq{%010u},$_)}(2**2*307*4993,5*101*641*5261,7*59*79 +*36997,13*17*71*45131,3**2*67*89*167*181))=~/\d{2}/g));'