Created
October 4, 2011 01:58
-
-
Save hayajo/1260740 to your computer and use it in GitHub Desktop.
pinboard
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/env perl | |
use strict; | |
use warnings; | |
use 5.008_001; | |
use File::Spec; | |
use File::Basename; | |
use lib File::Spec->catdir(dirname(readlink(__FILE__) || __FILE__), qw/extlib lib perl5/); | |
use Term::ReadKey; | |
use Log::Dispatch::Screen; | |
use Net::Delicious; | |
use Encode qw/encode_utf8/; | |
my $user = read_prompt(prompt => 'user: '); | |
my $pswd = read_prompt(prompt => 'pswd: ', noecho => 1); | |
my $pin = Net::Delicious->new({ | |
user => $user, | |
pswd => $pswd, | |
endpoint => 'https://api.pinboard.in/v1/', | |
#debug => 1, | |
}); | |
for my $p ($pin->recent_posts()) { | |
printf("%s\n", encode_utf8($p->description)); | |
} | |
sub read_prompt { | |
my $args = { @_ }; | |
my $prompt = $args->{prompt} || ''; | |
print $prompt; | |
ReadMode('noecho') if ( $args->{noecho} ); | |
my $in = ReadLine(0); | |
chomp $in; | |
ReadMode('restore'); | |
return $in; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment