Mercurial > hg > lukkari
changeset 160:a84b40bc2a99
Add parselist.pl utility and use it in update script.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 17 Aug 2015 22:02:22 +0300 |
parents | 66f3f02d5172 |
children | 62687fee6f1c |
files | parselist.pl update.sh |
diffstat | 2 files changed, 18 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/parselist.pl Mon Aug 17 22:02:22 2015 +0300 @@ -0,0 +1,17 @@ +#!/usr/bin/perl -w +use strict; +use warnings; + +my $patprefix = shift or die("Usage: $0 <prefix> <suffix>\n"); +my $patsuffix = shift or die("Usage: $0 <prefix> <suffix>\n"); + +while (defined(my $line = <STDIN>)) +{ + $line =~ s/^\s*//; + $line =~ s/\s*$//; + + while ($line =~ /<a href="$patprefix([A-Z]{3}\d\S+)$patsuffix">/ig) + { + print "$1\n"; + } +}
--- a/update.sh Mon Feb 09 16:33:27 2015 +0200 +++ b/update.sh Mon Aug 17 22:02:22 2015 +0300 @@ -15,7 +15,7 @@ PATPREFIX="$3" if wget -q -O "$LISTFILE" "$URLPREFIX"; then - perl -ne "if (/<a href=\"${PATPREFIX}([A-Z]{3}\d\S+)${URLSUFFIX}\">/) { print \"\$1\n\"; }" < "$LISTFILE" > "$CLASSFILE" + perl -w ./parselist.pl "$PATPREFIX" "$URLSUFFIX" < "$LISTFILE" > "$CLASSFILE" rm -f "$LISTFILE" echo -n "* Fetched classfile $CLASSFILE: " cat "$CLASSFILE" | wc -l