File: shift.pl

package info (click to toggle)
taktuk 3.7.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,252 kB
  • sloc: perl: 6,715; ansic: 1,211; makefile: 188; sh: 161
file content (39 lines) | stat: -rwxr-xr-x 548 bytes parent folder | download
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
#!/usr/bin/perl
use bytes;

my $source="A-Za-z0-9 ,.;:?!";
my $dest="M-Za-z0-9 ,.;:?!A-L";
my $mode;

if ($ARGV[0] eq "encode")
  {
    $mode = 0;
  }
elsif ($ARGV[0] eq "decode")
  {
    $mode = 1;
  }
else
  {
    die "Invalid mode";
  }
shift @ARGV;

my $line;
if ($mode)
  {
    while ($line = <>)
      {
        eval "\$line =~ tr/$dest/$source/";
        print $line;
      }
  }
else
  {
    while ($line = <>)
      {
        $line =~ tr//aaeeeeiiou/;
        eval "\$line =~ tr/$source/$dest/";
        print $line;
      }
  }