summaryrefslogtreecommitdiff
path: root/tweet-archive.pl
diff options
context:
space:
mode:
Diffstat (limited to 'tweet-archive.pl')
-rw-r--r--tweet-archive.pl25
1 files changed, 16 insertions, 9 deletions
diff --git a/tweet-archive.pl b/tweet-archive.pl
index 6e007d3..a1b5fff 100644
--- a/tweet-archive.pl
+++ b/tweet-archive.pl
@@ -1,8 +1,9 @@
#!/usr/bin/env perl
-use 5.024;
+use v5.36;
use strict;
use warnings;
-use Path::Class;
+use experimental 'try';
+use Path::Tiny;
use JSON::MaybeXS;
use Dakkar::TweetArchive;
use Dakkar::TweetArchive::Store;
@@ -13,10 +14,15 @@ my $json_parser = JSON::MaybeXS->new(
);
my $conf = $json_parser->decode(
- file(__FILE__)->parent->file('tweet-archive.conf')
- ->slurp(iomode=>'<:raw')
- // '{}'
- );
+ do {
+ try {
+ path(__FILE__)->sibling('tweet-archive.conf')->slurp_raw()
+ }
+ catch ($e) {
+ '{}'
+ }
+ },
+);
my $client = Dakkar::TweetArchive->new($conf);
my $store = Dakkar::TweetArchive::Store->new($conf);
@@ -25,7 +31,7 @@ my $ua = $client->client->ua;
my @responses;
$ua->add_handler( response_done => sub { push @responses, $_[0]; return } );
-eval {
+try {
my $latest_id = $store->latest_tweet_id;
for my $tweet ($client->home_timeline($latest_id)->@*) {
@@ -35,8 +41,9 @@ eval {
$store->store_friends($client->friends);
$store->store_followers($client->followers);
1;
-} or do {
- print "Fail: $@\n";
+}
+catch ($e) {
+ print "Fail: $e\n";
for my $res (@responses) {
next if $res->is_success;
print $res->request->as_string;