| 1 | package Crypt::Discordian; | ||
| 2 | |||
| 3 | 1 | ▶ | use Data::Dumper; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 1 | ▶ | use 5.006001; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 1 | require Exporter; | |
| 10 | |||
| 11 | 1 | our @ISA = qw(Exporter); | |
| 12 | |||
| 13 | # Items to export into callers namespace by default. Note: do not export | ||
| 14 | # names by default without a very good reason. Use EXPORT_OK instead. | ||
| 15 | # Do not simply export all your public functions/methods/constants. | ||
| 16 | |||
| 17 | # This allows declaration use Crypt::Discordian ':all'; | ||
| 18 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||
| 19 | # will save memory. | ||
| 20 | 1 | our %EXPORT_TAGS = ( 'all' => [ qw( | |
| 21 | |||
| 22 | ) ] ); | ||
| 23 | |||
| 24 | 1 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |
| 25 | |||
| 26 | 1 | our @EXPORT = qw( | |
| 27 | |||
| 28 | ); | ||
| 29 | |||
| 30 | 1 | our $VERSION = '0.01'; | |
| 31 | |||
| 32 | |||
| 33 | # Preloaded methods go here. | ||
| 34 | |||
| 35 | 2 | ▶ | sub normalize { |
|
Subroutine
normalize: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 36 | 2 | my $string = uc(shift); | |
| 37 | |||
| 38 | # remove spaces from string | ||
| 39 | 2 | $string =~ s/\s+//g; | |
| 40 | |||
| 41 | 2 | $string; | |
| 42 | } | ||
| 43 | |||
| 44 | 1 | ▶ | sub vowel_shift { |
|
Subroutine
vowel_shift: called CC=2 SCAR=6.9
Pod
undocumented
| |||
| 45 | 1 | my $string = normalize(shift); | |
| 46 | |||
| 47 | 1 | my $vowel = qr/[AEIOUY]/; | |
| 48 | |||
| 49 | |||
| 50 | # collect all occurences of vowels in order | ||
| 51 | 1 | my @vowel = ($string =~ m/$vowel/g) ; | |
| 52 | |||
| 53 | # remove all vowels from string | ||
| 54 | 1 | $string =~ s/$vowel//g; | |
| 55 | |||
| 56 | # append all vowels to end of string | ||
| 57 | 1 | $string = "$string$_" for @vowel; | |
| 58 | |||
| 59 | 1 | $string; | |
| 60 | } | ||
| 61 | |||
| 62 | 1 | ▶ | sub encrypt { |
|
Subroutine
encrypt: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 63 | 1 | my $string = normalize(shift); | |
| 64 | 1 | my @string; | |
| 65 | |||
| 66 | 1 | $string = vowel_shift $string; | |
| 67 | 1 | $string = reverse $string; | |
| 68 | 1 | @string = unpack 'C*', $string; | |
| 69 | 1 | @string = sort { $a <=> $b } @string; | |
| 70 | 1 | pack 'C*', @string; | |
| 71 | } | ||
| 72 | |||
| 73 | 1 | 1; | |
| 74 | __END__ | ||