Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: darkstalker/rnd_ebooks
base: f11637cfe9
...
head fork: darkstalker/rnd_ebooks
compare: ddace2b5d4
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 9 additions and 11 deletions.
  1. +9 −11 rnd_ebooks.pl
20 rnd_ebooks.pl
View
@@ -16,12 +16,10 @@
my $config = Config::Tiny->read("$ENV{HOME}/.rnd-ebooks")
or die("error reading config: " . Config::Tiny->errstr . "\n");
-sub cfg_read { $config->{connect_params}->{$_[0]} or die("invalid config: missing $_[0]\n"); }
-
-my $consumer_key = cfg_read('consumer_key');
-my $consumer_secret = cfg_read('consumer_secret');
-my $access_token_key = cfg_read('access_token_key');
-my $access_token_secret = cfg_read('access_token_secret');
+foreach (qw/consumer_key consumer_secret access_token_key access_token_secret/)
+{
+ die("invalid config: missing $_\n") unless ($config->{connect_params}->{$_});
+}
# pick a random pdf file
my @pdf_list = glob "$pdf_dir/*.pdf";
@@ -29,7 +27,7 @@
print "selected file: $pdf_selected\n";
# get page count
-my $page_count = (split ' ', `pdfinfo "$pdf_selected" | grep Pages`)[1];
+my (undef, $page_count) = split ' ', `pdfinfo "$pdf_selected" | grep Pages`;
# select a random page
my $sel_page = int(rand($page_count)) + 1;
@@ -63,9 +61,9 @@
# tweet it
my $api = Net::Twitter->new(
traits => [qw/OAuth API::REST/],
- consumer_key => $consumer_key,
- consumer_secret => $consumer_secret,
- access_token => $access_token_key,
- access_token_secret => $access_token_secret,
+ consumer_key => $config->{connect_params}->{consumer_key},
+ consumer_secret => $config->{connect_params}->{consumer_secret},
+ access_token => $config->{connect_params}->{access_token_key},
+ access_token_secret => $config->{connect_params}->{access_token_secret},
);
$api->update($line_selected);

No commit comments for this range

Something went wrong with that request. Please try again.