-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "similar"; add examples; version to 0.05
- Loading branch information
1 parent
4e58610
commit 4a97ea6
Showing
10 changed files
with
194 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/home/ben/software/install/bin/perl | ||
use warnings; | ||
use strict; | ||
use utf8; | ||
use Unicode::Confuse ':all'; | ||
|
||
binmode STDOUT, ":encoding(utf8)"; | ||
|
||
sub obfuscate | ||
{ | ||
for (@_) { | ||
my @letters = split '', $_; | ||
my $out = ''; | ||
my $ok; | ||
for my $letter (@letters) { | ||
my @similar = similar ($letter); | ||
if (@similar) { | ||
$ok = 1; | ||
my $n = scalar (@similar); | ||
my $r = int (rand ($n)); | ||
$out .= $similar[$r]; | ||
} | ||
else { | ||
$out .= $letter; | ||
} | ||
} | ||
if (! $ok) { | ||
print "No confusables in '$_'.\n"; | ||
} | ||
else { | ||
print "$_ -> $out\n"; | ||
} | ||
} | ||
} | ||
|
||
obfuscate ('paypal', '月火水木金土日'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/home/ben/software/install/bin/perl | ||
use warnings; | ||
use strict; | ||
use utf8; | ||
use Unicode::Confuse ':all'; | ||
binmode STDOUT, ":encoding(utf8)"; | ||
if (confusable ('ρ')) { | ||
my $canonical = canonical ('ρ'); | ||
print "'ρ' is confusable with $canonical.\n"; | ||
my @similar = similar ($canonical); | ||
print "$canonical is also confusable with @similar.\n"; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/home/ben/software/install/bin/perl | ||
|
||
# The CPAN perl-reversion script seems to be making a muddle of things | ||
# sometimes, and it doesn't edit Changes, so I've made my own script. | ||
|
||
use warnings; | ||
use strict; | ||
use utf8; | ||
use FindBin '$Bin'; | ||
use File::Slurper qw!read_text write_text!; | ||
use Deploy 'make_date'; | ||
|
||
my $newversion = '0.05'; | ||
my $version = '0.04'; | ||
|
||
my @pmfiles = qw! | ||
lib/Unicode/Confuse.pm | ||
lib/Unicode/Confuse/Parse.pm | ||
!; | ||
|
||
for my $file (@pmfiles) { | ||
my $bfile = "$Bin/$file"; | ||
my $text = read_text ($bfile); | ||
if ($text =~ s/\Q$version\E\b/$newversion/g) { | ||
print "$file OK\n"; | ||
write_text ($bfile, $text); | ||
} | ||
elsif ($text =~ /\Q$newversion/) { | ||
warn "$file already at $newversion"; | ||
} | ||
else { | ||
warn "$file failed"; | ||
} | ||
} | ||
|
||
my $date = make_date ('-'); | ||
my $changes = "$Bin/Changes"; | ||
my $text = read_text ($changes); | ||
my $latest = <<EOF; | ||
$newversion $date | ||
- | ||
EOF | ||
|
||
if ($text =~ s/(\Q$version\E)/$latest$1/g) { | ||
write_text ($changes, $text); | ||
} | ||
else { | ||
warn "$changes failed"; | ||
} | ||
|
||
|