-
-
Save aanoaa/3918093 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
my $str = $ARGV[0] or die "usage: $0 <string>\n"; | |
my $LOWER_BEGIN = ord('a'); | |
my $LOWER_END = ord('z'); | |
my $UPPER_BEGIN = ord('A'); | |
my $UPPER_END = ord('Z'); | |
my @char = split(//, $str); | |
for my $c (@char) { | |
my $n = ord($c); | |
if ($n >= $LOWER_BEGIN && $n <= $LOWER_END) { | |
print lower_char(); | |
} else { | |
print upper_char(); | |
} | |
} | |
sub lower_char { | |
return chr(rand($LOWER_END - $LOWER_BEGIN) + $LOWER_BEGIN); | |
} | |
sub upper_char { | |
return chr(rand($UPPER_END - $UPPER_BEGIN) + $UPPER_BEGIN); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment