#!/usr/bin/perl use strict; use warnings; use Devel::Refactor; my $subname = shift @ARGV; my $codefile = shift @ARGV; open my $fh, $codefile or die ("Arrrrgh: $!"); my $old_code =join( "\n", <$fh>); close $fh; my $refactory = Devel::Refactor->new; my ($new_sub_call,$new_code) = $refactory->extract_subroutine($subname,$old_code); print "\n# sub call\n",$new_sub_call, "\n\n#sub definition\n", $new_code;