Created
March 9, 2013 08:03
-
-
Save mattdees/5123411 to your computer and use it in GitHub Desktop.
Query a random command from commandlinefu.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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