Advertisement
Guest User

report_questions

a guest
Feb 27th, 2011
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.56 KB | None | 0 0
  1. #! /usr/bin/env perl
  2.  
  3. ## Usage: $0 http://stackoverflow.com/ questions.json ...
  4.  
  5. use strict;
  6. use warnings;
  7. use File::Slurp qw(slurp);
  8. use JSON;
  9.  
  10. my $root = $ARGV[0]; shift; $root =~ s!/$!!;
  11.  
  12. my @questions =
  13.   sort {$a->{question_id} <=> $b->{question_id}}
  14.   map {@{$_->{questions}}}
  15.   map {from_json(slurp($_))} @ARGV;
  16.  
  17. foreach my $q (@questions) {
  18.     my $title = $q->{title}; $title =~ s/([*<>\[\]\`\\])/\\$1/g;
  19.     my $url = "$root/questions/" . $q->{question_id};
  20.     my $answers = $q->{answer_count};
  21.     print "* [$title]($url) ($answers)\n";
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement