root / dotorg / v9 / html / textreplace

Revision 10154, 2.9 kB (checked in by dave, 11 months ago)

Update copyright from 2006 to 2008.
Update four years of development to five.

  • Property svn:executable set to *
Line 
1#!/usr/bin/perl
2
3###
4# textreplace
5#
6# This accepts a list of files and performs in-place text replacement.
7# In otherwords, BACKUP YOUR FILES BEFORE YOU USE TEXTREPLACE.
8#
9# Usage:
10#   textreplace [[[file1] [file2] ... ]
11#
12# If no files are specified on the command line then this accepts a
13# whitespace delimited list of files from stdin.
14#
15# The type of text replacement is hard-coded, but I can easily change it
16# as needed... (So it's not perfect. Who cares?)
17#
18# by David Harrison   9/23/96
19###
20
21MAIN:
22{
23  print "textreplace begin...\n";
24  if (!@ARGV) {
25    @ARGV = <STDIN>;
26    #chop(@ARGV)   <--- What does this do?
27  }
28  foreach $file ( @ARGV ) {
29    print $file . "\n";
30
31    # move the file to a temporary file.
32    $file =~ s/\n//g;  # eliminate trailing newline from filename.
33    $infile = "harrisod_textreplace";
34    rename $file, $infile;
35
36    # use the temporary file as input to our text replacement operators.
37    open(INFILE, $infile) || die "can't read $file";
38
39    # output back to the original file.
40    open(OUTFILE, ">" . $file) || die "can't modify $file";
41
42    # process the file.  <file> reads a line into $_
43    while ( <INFILE> ) {
44      # perform substitution on $_
45      #s/BOOL/bool/g;
46      #s/TRUE/true/g;
47      #s/FALSE/false/g;
48      #s/seeder01.bittorrent.com/seeder-01.griffith.bit/g;
49      #s/seeder-03.griffith/seeder-03.griffith.bit/g;
50      #s/seeder1.bittorrent.com/38.99.5.17/g;
51      #s/seeder2.bittorrent.com/38.99.5.16/g;
52      #s/seeder3.bittorrent.com/38.99.5.15/g;
53      #s/GNU Public License/MIT License/g;
54      #s/sleep/wait/g;
55      #s/utorrent/BitTorrent/g;
56      #s/vp03-23.swf/player.swf/g;
57      #s/scripts\//\.\.\/scripts\//g;
58      #s/\.\.\/\.\.\/scripts/..\/scripts/g;
59      #s/things\/cache/things\/dna_streaming_mockup\/cache/g;
60      #s/video_player_06_20_07.swf/video_player_06_22_07.swf/g;
61      #s/brightcove/demo/g;
62      #s/download.bittorrent.com\/public\/things/demo.bittorrent.com/g;
63      #s/player_06_22_07/player_080207/g;
64      #s/swfobject.js/swfobject_1-5.js/g;
65      #s/dna_streaming_mockup/dna_plugin/g;
66      #s/video_player_080207/player_080207/g;
67      #s/demo.bittorrent.com\/dna_plugin/demo.bittorrent.com\/dx14fv/g;
68      #s/demo.bittorrent.com/download.bittorrent.com\/public\/dx14fv/g;
69      #s/public\/things\/dx14fv/public\/dx14fv/g;
70      #s/dx14fv\/dx14fv/dx14fv/g;
71      #s/download.bittorrent.com\/public\/dx13fv\/cache_/demo.bittorrent.com\/dna_streaming_mockup\/cache_/g;
72      #s/player_080207.swf/player.swf/g;
73      #s/demo.bittorrent.com/download.bittorrent.com\/public\/things/g;
74      #s/btdna\(/encodeURIComponent\(btdna\(/g;
75      #s/}\)\);/}\)\)\);/g;
76      #s/\r/\n/g;
77      s/2006 BitTorrent.org/2008 BitTorrent.org/g;
78     
79      # output $_ to $file
80      print OUTFILE;
81    }
82
83    # close the input and output files.
84    close INFILE;
85    close OUTFILE;
86
87    # remove the temporary file.
88    unlink $infile
89  }
90
91}
92
Note: See TracBrowser for help on using the browser.