-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnucut.pl
67 lines (56 loc) · 1.16 KB
/
nucut.pl
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#################################################
#nucut.pl : originally nudge-cut, to cut from nudge table and create commands
#expanded to twiddling the final 2 letters of a command
#
use strict;
use warnings;
use Win32::Clipboard;
my $clip = Win32::Clipboard::new();
my $x = $clip->Get();
my $clipStr = "";
my @y = split(/\n/, $x);
print "" . ($#y+1) . " total lines.\n";
for (@y)
{
my $z = $_;
$z =~ s/[\n\r\t]*$//g;
if ($z =~ /^>/)
{
$z =~ s/ //g;
$z = lastTwid($z);
$clipStr .= "$z\nWRONG\n$_\nYour score has just gone up by one point.\n$z\nWRONG\n";
}
elsif ($z =~ /\t/)
{
my @z2 = split(/\t/, $z);
$z2[0] =~ s/\"//g;
$z2[0] = lastTwid($z2[0]);
$z2[$#z2] =~ s/\"//g;
$clipStr .= ">$z2[0]\n$z2[$#z2]\n";
}
elsif ($z !~ /[a-z]/i) { $clipStr .= "\n"; }
else
{
$clipStr .= $z;
}
}
print $clipStr;
$clip->Set($clipStr);
sub lastTwid
{
my @let = split(//, $_[0]);
my $idx = $#let - 1;
while ($idx > 0)
{
#print "$let[$idx] vs $let[$#let]\n";
if ("$let[$idx]" ne "$let[$#let]")
{
my $temp = $let[$idx];
$let[$idx] = $let[$#let];
$let[$#let] = $temp;
return join("", @let);
}
$idx--;
}
return $_[0];
}