diff options
author | Nick Shipp <nick@shipp.ninja> | 2017-06-03 01:33:15 -0400 |
---|---|---|
committer | Nick Shipp <nick@shipp.ninja> | 2017-06-03 01:33:15 -0400 |
commit | 40f17d1f4bd03c48cb89a6e70e9cd7a3259334c6 (patch) | |
tree | 5984140fe779d76aac734bf0cc1474c2a03bddce /url |
Diffstat (limited to 'url')
-rwxr-xr-x | url | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -0,0 +1,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}->($_); + } +} |