melo / scripts

My personal script stash

This URL has Read+Write access

scripts / bin / x-bork-bork-bork
100755 55 lines (41 sloc) 1.079 kb
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/perl -w
#
# Filters text into bork-bork-bork
#
# You send in some text like this little explanation and you'll
# get this:
#
# Yuoo send een sumea text leekea thees leettlea ixplunashun und yuoo'll
# get thees
#
# Pedro Melo <melo@simplicidade.org>
 
use strict;
use warnings;
use Getopt::Long;
 
my $help;
my $ok = GetOptions("help|?" => \$help);
 
usage() if !$ok || $help;
 
require_module('Lingua::Bork', qw(bork));
 
print bork($_) while (<>);
 
#################################
# My little require module method
 
sub require_module {
  my $module = shift;
  
  eval "require $module";
  if (my $e = $@) {
    print STDERR "FATAL: $0 requires the Perl module '$module'.\n\n";
    print STDERR "You can install it with:\n\n";
    print STDERR " cpan $module\n\n";
    exit(1);
  }
  $module->import(@_);
}
 
sub usage {
  print STDERR <<USAGE;
Usage: x-bork-bork-bork [--help] [-?] [input files]
 
Reads the input files, translates them into Bork, Bork, Bork, and sends
the result to stdout.
 
If no input files are given, it will read from stdin.
 
USAGE
  exit(1);
}