#!/usr/npac/bin/perl

#$sourcedir="/usr/local/archives/public/html/users/haupt/HPFI/";
$sourcedir="/tmp/source/";
$destdir="/tmp/dest/";

$oldstring="osprey4.npac.syr.edu";
$newstring="cygnus.npac.syr.edu";

$ext=".java";

opendir(FH,$sourcedir) || die "cannot open dir $sourcedir: $!";
@files=readdir(FH);
close FH;

@files=grep /$ext$/, @files;

foreach $file (@files) {

    $srcfile = $sourcedir.$file;
    $dstfile = ">".$destdir.$file;
    open(SRC, $srcfile) || "cannot open file $srcfile: $!";
    open(DST, $dstfile) || "cannot open file $dstfile: $!";
    while (<SRC>) {
	$line = $_;
        print $line;
        $line =~ s/$oldstring/$newstring/g;
        print DST $line;
        print $line;
    }
    close SRC;
    close DST;
    print "file $file processed\n";
}

