Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added postfix comments for clarity.

  • Loading branch information...
commit 95b8aef1c4f7d22c2b1182327403ef5c3ce4f51f 1 parent 38b0567
@conorsch conorsch authored
Showing with 10 additions and 10 deletions.
  1. +10 −10 RedditRIL.pm
View
20 RedditRIL.pm
@@ -6,8 +6,8 @@ use LWP::Simple;
use XML::RSS::Parser::Lite;
use Text::Match::FastAlternatives;
-my $ril_api_key = "5c2A5U01d2f4fR3f3cp5cF7NU6TKLG6b";
-my $ril_login;
+my $ril_api_key = "5c2A5U01d2f4fR3f3cp5cF7NU6TKLG6b"; #Application's API key for RIL/Pocket service;
+my $ril_login; #Initializing variables to be available package-wide;
my $ril_pass;
my $ril_url;
@@ -19,14 +19,14 @@ sub new {
return $self;
}
-sub process_subreddit {
+sub process_subreddit {
# Process a subreddit,
# Get a subreddit name & keywords
# as argument
- my ($self, $sub, $kws) = @_;
- my $parser = XML::RSS::Parser::Lite->new();
+ my ($self, $sub, $kws) = @_; #unpack variables from function caller;
+ my $parser = XML::RSS::Parser::Lite->new(); #Create new parser;
$parser->parse(get("http://www.reddit.com/r/$sub/new/.rss?limit=5&t=all&sort=new")) or die ("Erf.. a error occured :\n\t$!");
- my $re = join "|", @{$kws};
+ my $re = join "|", @{$kws}; #Stitch together easy list of keywords;
my $nothing = 1; # just for cosmetic purpose ;)
for (my $i = 0; $i < $parser->count(); $i++) {
my $item = $parser->get($i);
@@ -38,10 +38,10 @@ sub process_subreddit {
say "\tNothing to do here..." if $nothing;
}
-sub add_to_ril {
- my ($self,$item) = @_;
- say "+ Adding link $item->{url}\n\t[$item->{title}]";
+sub add_to_ril { #Submit link to RIL/Pocket service;
+ my ($self,$item) = @_; #Unpack variables from function caller;
+ say "+ Adding link $item->{url}\n\t[$item->{title}]"; #Provide feedback;
get("$ril_url&url=$item->{url}&title=$item->{title}") or die ("Unable to upload link to RIL...\n\t$!");
- say("\t=> Done uploading !");
+ say("\t=> Done uploading !"); #Announce that we're finished here;
}
1;
Please sign in to comment.
Something went wrong with that request. Please try again.