#!/usr/bin/perl

while( $ARGV[0] ne "" ) {
    if( -f $ARGV[0] ) {
	$tmpfile = $ARGV[0] . ".bak";
	$ARGV[0] =~ /^(.*?).php3$/;
	if( $1 ne "" ) {
	    $outfile = $1 . ".php";
	    print "Converting $ARGV[0] -> $outfile\n";
	    system "mv $ARGV[0] $tmpfile";
	    open( INPUT, "< $tmpfile" ) or die("Couldn't open $tmpfile for reading\n");
	    open( OUTPUT, "> $outfile" ) or die("Couldn't open $tmpfile for writing\n");
	    while( <INPUT> ) {
		s/\.php3/\.php/;
		print OUTPUT $_;
	    }
	    system "rm $tmpfile";
	}
    }
    shift;
}
