Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
inoboft mulode to mses anorud with the ierantnl oderr of ltreets on r…
…eeusqt
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#------------------------------------------------------------------------ | ||
# Rot13 command | ||
# | ||
# ROT13s a random bit of text. | ||
# | ||
# $Id: rot13.pm,v 1.7 2001/12/13 18:30:51 awh Exp $ | ||
#------------------------------------------------------------------------ | ||
|
||
use strict; | ||
package hardlycrypt; | ||
use List::Util qw/shuffle/; | ||
|
||
sub scan(&$$) { | ||
my ($callback,$message,$who) = @_; | ||
|
||
if ($message =~ /^rot13\s+(.*)/i) { | ||
# rot13 it | ||
my $reply = hardlycrypt($1); | ||
$callback->($reply); | ||
return "NOREPLY"; | ||
} | ||
undef; | ||
} | ||
|
||
sub hardlycrypt { | ||
my $phrase = shift; | ||
my @words = split /\b/, $phrase; | ||
my $reply; | ||
foreach (@words) { | ||
my @word = split //, $_; | ||
if ( scalar(@word <= 2) ) { | ||
$reply .= join '', @word; | ||
} | ||
else { | ||
$DB::single=1; | ||
my $front = $word[0]; | ||
my $end = $word[$#word]; | ||
my $mid = join '', shuffle(@word[1 .. ($#word-1)]); | ||
$reply = $reply . $front . $mid . $end ; | ||
} | ||
} | ||
return $reply; | ||
} | ||
|
||
"hardlycrypt"; |