Shell::DSL - Run and pipe commands from one to another like you would in Bash.
NAME
Shell::DSL - Run and pipe commands from one to another like you would in Bash.
NOTE: This module is not thread-safe.
Caveat: Although an implementation detail, this module currently depends on Bash to connect the pipes and to set up user specified I/O redirections for sub processes.
SYNOPSIS
use Shell::DSL;
my @words;
shell :!pipefail, {
.curl<-fsSL https://en.wikipedia.org/wiki/Special:Random>
|> .xmllint(Ā«--html --xpath '//*[name()!="script"]/text()' -Ā», (:w2</dev/null>))
|> .tr<-cs A-Za-z \n>
|> .tr<A-Z a-z>
|> .sort
|> .uniq<-c>
|> .sort<-rn>
|> .head<-30>
|> pb({
for .lines {
my $match = $_ ~~ /\s* \d+ ' ' (\w+)$/;
next if !$match;
@words.push: $match[0];
.put;
}
})
|> .nl;
}
put();
my $i = (^@words).pick;
say "The word, '@words[$i]', is No. {$i+1} in the list.";
See examples/ for more usage examples.
AUTHOR
Jack Kuan <[email protected]>
COPYRIGHT AND LICENSE Copyright 2020 Jack Kuan
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.