Next Making Programs Faster 18

Wallclock Time

        # usage: webgrep PATTERN urls...
        use LWP::Simple 'get';
        my $pat = shift;
        my @contexts;
        for my $url (@ARGV) {
          my $doc = get($url);
          unless (defined $doc) {
            warn "Couldn't fetch $doc; skipping\n";
            next;
          }
          while ($doc =~ m/$pat/oig) {
            push @contexts, substr($doc, pos($doc) - 30, 60);
          }
        }
        print join("\n--------\n", @contexts), "\n";

Next Copyright © 2003 M. J. Dominus