blob: c4c76db7d2b74e5f8378cfd398f29a79d929209f (
plain)
| 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
 | #!/usr/bin/env perl
use feature 'say';
use URL::Encode qw(:all);
use String::ShellQuote;
my %commands = (
    encode => sub { say url_encode(shift) },
    decode => sub { say url_decode(shift) },
);
die "Usage: $0 <${\join '|',keys %commands}> ARGS" unless @ARGV >= 1;
my $command = shift;
die "No such command $command" unless defined $commands{$command};
if (@ARGV) {
    for (@ARGV) {
        $commands{$command}->($_);
    }
} else {
    while (<STDIN>) {
        chomp;
        $commands{$command}->($_);
    }
}
 |