File: factory.pl

package info (click to toggle)
libdevel-refactor-perl 0.05-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 132 kB
  • sloc: perl: 520; makefile: 2
file content (25 lines) | stat: -rwxr-xr-x 590 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/perl
use Data::Dumper;
use Devel::Refactor; 

$|++;

# Get the contents of the clipboard.  Requires dcop from KDE.
my $clipboard = `dcop klipper klipper getClipboardContents`;

print "Subroutine Name? ";
my $name = <STDIN>;

chomp $name;

my $refactory = Devel::Refactor->new;
my ($new_sub_call,$new_code) = $refactory->extract_subroutine($name,$clipboard);

my $retval = $new_sub_call . $new_code;

# protect quotes and dollar signs
$retval =~ s/\"/\\"/g;
$retval =~ s/(\$)/\\$1/g;

#Put the results back on the clipboard.
`dcop klipper klipper setClipboardContents "$retval"`;