Annotation of db/prgsrc/changecities.pl, revision 1.2

1.1       boris       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: 
1.2     ! boris      19: =over 4
1.1       boris      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: 
1.2     ! boris      29: =back
1.1       boris      30: 
                     31: =head1 AUTHOR
                     32: 
                     33: Boris Veytsman
                     34: 
1.2     ! boris      35: =head1 $Id: changecities.pl,v 1.1 2000/10/17 15:05:48 boris Exp boris $
1.1       boris      36: 
                     37: =cut
1.2     ! boris      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: }
1.1       boris      62: 

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