File:  [Local Repository] / db / prgsrc / changecities.pl
Revision 1.2: download - view: text, annotated - select for diffs - revision graph
Tue Oct 17 15:33:46 2000 UTC (23 years, 7 months ago) by boris
Branches: MAIN
CVS tags: HEAD
Wrote the program

    1: #!/usr/bin/perl
    2: 
    3: =head1 NAME
    4: 
    5: changecities.pl -- analyze DB changelog to substitute cities
    6: 
    7: =head1 SYNOPSIS
    8: 
    9: changecities.pl B<-c> ChangeLog -d <directory>
   10: 
   11: =head1 DESCRIPTION
   12: 
   13: The program looks at all html files in the I<directory> and substitutes 
   14: C<tour=oldcity> by C<tour=newcity> for each line like
   15:   oldcity -> newcity
   16: 
   17: in the ChangeLog
   18: 
   19: =over 4
   20: 
   21: =item B<-c> ChangeLog
   22: 
   23: Location of the ChangeLog file
   24: 
   25: =item B<-d> directory
   26: 
   27: Directory of html files
   28: 
   29: =back
   30: 
   31: =head1 AUTHOR
   32: 
   33: Boris Veytsman
   34: 
   35: =head1 $Id: changecities.pl,v 1.2 2000/10/17 15:33:46 boris Exp $
   36: 
   37: =cut
   38: 
   39:     use strict;
   40: use vars qw($opt_c $opt_d);
   41: use Getopt::Std;
   42: 
   43: getopts('c:d:') or die "Wrong arguemnts";
   44: open (CHANGELOG, $opt_c) or die "Cannot open ChangeLog $opt_c";
   45: chdir $opt_d or die "Cannot chdir to $opt_d";
   46: while (<CHANGELOG>) {
   47:     chomp;
   48:     next unless (/->/);
   49:     m/^\s*(\S*)\.txt\s*->\s*(\S*)\.txt/ or print "Bad line: $_";
   50:     my $oldname=$1;
   51:     my $newname=$2;
   52:     print "Changing $oldname to $newname\n";
   53:     open(FILES, "grep -l \'tour=$oldname\' *.html|");
   54:     while(<FILES>) {
   55: 	chomp;
   56: 	my $file = $_;
   57: 	print "CONVERTING $file.";
   58: 	`perl -iorig -p -e 's/tour=$oldname/tour=$newname/g' $file`;
   59: 	print "..\n";
   60:     }
   61: }
   62: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>