Skip to content

Instantly share code, notes, and snippets.

@mattdees
Created March 9, 2013 08:03
Show Gist options
  • Save mattdees/5123411 to your computer and use it in GitHub Desktop.
Save mattdees/5123411 to your computer and use it in GitHub Desktop.
Query a random command from commandlinefu.com
#!/usr/bin/perl
use HTTP::Tiny;
use JSON;
my $command ='random';
#my $command = 'browse/last-week/sort-by-votes';
my $url = "http://www.commandlinefu.com/commands/${command}/json/";
#print Dumper $res;
my $data = decode_json( HTTP::Tiny->new()->get($url)->{'content'} );
foreach my $trick ( @{ $data } ) {
print $trick->{'summary'} . ":\n" . $trick->{'command'} . "\n\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment