$code = get_selection() if ( $code != "" ) { $subname = string_dialog( "New sub name:", "OK" ) # fichier temporaire $processnum = shell_command("echo $$", "") $processnum = replace_in_string($processnum, "\n", "") $tmpfile = "/tmp/nedit" $processnum write_file( $code, $tmpfile ) $codestring = "/home/emmanuel/bin/refactor.pl " $subname " " $tmpfile if ( $subname != "" ) { $subgen = shell_command( $codestring, "" ) if ( $subgen != "" ) { replace_selection( $subgen ) } } # delete temp file shell_command( "rm " $tmpfile, "") } #### #!/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;