source: bookmarks/trunk/scan @ 98

Last change on this file since 98 was 88, checked in by peter, 9 years ago

Better separation of the model for searching and the web app controller/representation layer

  • renamed Bookmarks::get_bookmarks() to search()
  • Bookmarks::search() now returns a Bookmarks::Search object instead of a Bookmarks::List
  • search results now reside in the Bookmarks::Search class
  • Property svn:executable set to *
File size: 777 bytes
RevLine 
[72]1#!/usr/bin/perl -w
2use strict;
3
4use Bookmarks;
5use LWP::UserAgent;
6use Text::CSV;
7use Getopt::Long;
8
9GetOptions(
10    'csv' => \my $CSV,
11    'timeout=i' => \my $TIMEOUT,
12);
13
14my $DBFILE = shift or die "Usage: $0 <dbfile>";
15
16$TIMEOUT ||= 10;
17
18my $bookmarks = Bookmarks->new({
19    dbname => $DBFILE,
20});
21
22my $ua = LWP::UserAgent->new;
23$ua->timeout($TIMEOUT);
24
25my $csv = Text::CSV->new;
26
[88]27for my $bookmark (@{ $bookmarks->search->results }) {
[72]28    printf "%3d %s\n", $bookmark->id, $bookmark->uri unless $CSV;
29    my $response = $ua->head($bookmark->uri);
30    printf "   -> %s\n", $response->status_line unless $CSV;
31    $csv->combine(
32        $bookmark->id,
33        $bookmark->uri,
34        $response->code,
35        $response->message,
36    );
37    print $csv->string . "\n" if $CSV;
38}
Note: See TracBrowser for help on using the repository browser.