| 1 | #!/usr/bin/perl | ||
| 2 | use lib "."; | ||
| 3 | |||
| 4 | # poke.pl - sample script to illustrate how the WebCache::Digest code can | ||
| 5 | # can be used to create Digests for lists of URLs | ||
| 6 | |||
| 7 | # $Id: dpoke.pl,v 1.1 1999/03/12 17:55:33 martin Exp martin $ | ||
| 8 | |||
| 9 | use Getopt::Std; | ||
| 10 | use WebCache::Digest; | ||
| 11 | |||
| 12 | getopts("duv"); | ||
| 13 | |||
| 14 | $d = new WebCache::Digest; | ||
| 15 | $d->create(capacity => 1000); | ||
| 16 | |||
| 17 | $|=1; | ||
| 18 | |||
| 19 | print "> time is: " . localtime(time) . "\n" if $opt_d; | ||
| 20 | |||
| 21 | while(<STDIN>) { | ||
| 22 | chop; | ||
| 23 | s/\s+/ /g; | ||
| 24 | if ($opt_u) { | ||
| 25 | $url = $_; | ||
| 26 | } else { | ||
| 27 | @bits = split; | ||
| 28 | $url = $bits[6]; | ||
| 29 | } | ||
| 30 | |||
| 31 | $d->register("GET", $url); | ||
| 32 | print "$url\n" if $opt_v; | ||
| 33 | } | ||
| 34 | |||
| 35 | $d->save($ARGV[0]); | ||
| 36 | |||
| 37 | print "> time is: " . localtime(time) . "\n" if $opt_d; | ||
| 38 | |||
| 39 | |||
| 40 | =head1 NAME | ||
| 41 | |||
| 42 | poke.pl - create Cache Digests from lists of URLs | ||
| 43 | |||
| 44 | =head1 SYNOPSIS | ||
| 45 | |||
| 46 | echo http://www.w3.org | dpoke.pl -duv saved-digest | ||
| 47 | dpoke.pl saved-digest < old-access-log | ||
| 48 | zcat old-access-log.gz | dpoke.pl -v saved-digest | ||
| 49 | |||
| 50 | =head1 DESCRIPTION | ||
| 51 | |||
| 52 | This program lets you create a Cache Digest from a list of URLs | ||
| 53 | supplied via STDIN. This will then be saved to disk. The list of URLs | ||
| 54 | can be in Squid log file format (the default), or simply a list of URLs | ||
| 55 | (when the B<-u> argument is supplied). | ||
| 56 | |||
| 57 | =head1 OPTIONS | ||
| 58 | |||
| 59 | =over 4 | ||
| 60 | |||
| 61 | =item -d | ||
| 62 | |||
| 63 | Debug mode - causes helpful debugging messages to be printed | ||
| 64 | |||
| 65 | =item -u | ||
| 66 | |||
| 67 | Input is a list of URLs rather than Squid log file format. | ||
| 68 | |||
| 69 | =item -v | ||
| 70 | |||
| 71 | Verbose mode - causes each URL being added to the Digest to be printed | ||
| 72 | to STDOUT. | ||
| 73 | |||
| 74 | =back | ||
| 75 | |||
| 76 | =head1 COPYRIGHT | ||
| 77 | |||
| 78 | Copyright (c) 1999, Martin Hamilton. All rights reserved. | ||
| 79 | |||
| 80 | This program is free software; you can redistribute it and/or modify | ||
| 81 | it under the same terms as Perl itself. | ||
| 82 | |||
| 83 | It was developed by the JANET Web Cache Service, which is funded by | ||
| 84 | the Joint Information Systems Committee (JISC) of the UK Higher | ||
| 85 | Education Funding Councils. | ||
| 86 | |||
| 87 | =head1 AUTHOR | ||
| 88 | |||
| 89 | Martin Hamilton E<lt>martinh@gnu.orgE<gt> | ||
| 90 |