-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdash.pl
67 lines (56 loc) · 1.38 KB
/
dash.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
#########################################################################
#dash.pl
#check hyphens and dashes to see if they're excessive
#
#no arguments needed
use strict;
use warnings;
my $roil = "c:/Program Files (x86)/Inform 7/Inform7/Extensions/Andrew Schultz/Roiling Random Text.i7x";
my $sa = "c:/Program Files (x86)/Inform 7/Inform7/Extensions/Andrew Schultz/Shuffling Random Text.i7x";
my $count = 0, my $frag = 0, my $subs = 0;
my %hyphe;
my %wrd;
my @b, my @c;
readHash($sa);
readHash($roil);
hyphe($sa);
hyphe($roil);
##################################subroutines
sub readHash
{
open(A, "$_[0]");
while ($a=<A>)
{
if ($a !~ /^\"/) { next; }
$a = <A>; chomp($a); $a = lc($a); @b = split(/\b/, $a); for (@b) { $wrd{$_}=1; }
}
close(A);
}
sub hyphe
{
my $line = 0;
open(A, "$_[0]");
while ($a=<A>)
{
$line++;
if ($a !~ /^\"/) { next; }
$a = <A>; chomp($a); $a = lc($a);
@b = split(/[^a-z-]/, $a);
for (@b)
{
if ($_ =~ /-/)
{
if ($hyphe{$_}) { $count++; print "($line) Duplicate hyphen $count $_\n"; }
$hyphe{$_} = 1;
@c = split(/-/, $_); $subs = 0; for $frag (@c) { if ($wrd{$frag}) { $subs++; } }
if ($subs > 2) { if (alfy($c[0]) eq alfy($c[1])) { print "($line) $_ is an overused hyphen, maybe.\n"; } }
}
}
}
close(A);
}
sub alfy
{
my @z = split(//, $_[0]);
return join('', sort(@z));
}