#! /usr/bin/env perl
use Getopt::Long;
use Cwd;


my $node = $ARGV[0];

GetOptions 
(
		'help' => \$help,
);

#$log = "Just Do IT!\n";
if ( $log )    
{
	my $LogFile = "adjustinput.log";
	print "Build log will be in ---$LogFile---\n";
	open(OLDOUT, ">&STDOUT");
	open(OLDERR, ">&STDERR");
	open(STDOUT, ">>$LogFile") or die "Could not open $LogFile: $!\n";
	open(STDERR, ">&STDOUT");
	select(STDERR); $| = 1;
	select(STDOUT); $| = 1;
}
if($help) { help() and exit(0); }

print "*****************************Process Node <<<< $node >>>>*************************\n";
my $base = "";
opendir(DIR,".") || die "Can't open current directory: $!\n";
while( defined($file = readdir(DIR)))
{
	if( -d $file )
	{
		print "Skip  directories($file)\n";
	}
	else
	{
		#print "$file\n";
		my $savefile = "";
		if($file =~ /(.*).new/)
		{
			$base = $1;
			$savefile = $base . "." . $node;
			print "base found is $1\n";
			print "Going to copy it to $savefile\n";
			system("cp $base.new $savefile");
			system("mv $base.new $base");
		}
	}
}

# =================================
# print help
# =================================

sub help
{
	print "Usage: structure.pl --images=../Images --buildloc=ForestryJob
		Options:
			[-h/--help]                             See this
			[-i/--images]                           <<--images=../Images>> use these images
			\n";
}

