From 40f17d1f4bd03c48cb89a6e70e9cd7a3259334c6 Mon Sep 17 00:00:00 2001 From: Nick Shipp Date: Sat, 3 Jun 2017 01:33:15 -0400 Subject: Initial commit --- url | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 url (limited to 'url') diff --git a/url b/url new file mode 100755 index 0000000..c4c76db --- /dev/null +++ b/url @@ -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 () { + chomp; + $commands{$command}->($_); + } +} -- cgit v1.2.3-54-g00ecf