All pastes #612949 Raw Edit

Something

public text v1 · immutable
·published 2007-07-10 18:45 UTC
rendered paste body
#!/usr/bin/perl

use Getopt::Long;

GetOptions("wood=i"=>\$wood,"w=i" =>\$wood,
	   "clay=i"=>\$clay, "c=i" =>\$clay,	   
	   "iron=i" =>\$iron, "i=i" =>\$iron,
	   "food=i" =>\$food, "f=i" =>\$food);

if (!((defined $wood) || (defined $clay) || (defined $iron) || (defined $food))) { die ("At least one of wood(w), clay(c), iron(i), food(f) must be specified!"); }

print "waiting for resources: ";
if (defined $wood) { print "wood:$wood "; }
if (defined $clay) { print "clay:$clay "; }
if (defined $iron) { print "iron:$iron "; }
if (defined $food) { print "food:$food "; }
print "\n";
do
{
  $resources = `./resources.pl`;
  
  ($currwood,$wp) = $resources =~ m|wood,(\d+),(\d+)|g;
  ($currclay,$cp) = $resources =~ m|clay,(\d+),(\d+)|g;
  ($curriron,$ip) = $resources =~ m|iron,(\d+),(\d+)|g;
  ($currfood,$fp) = $resources =~ m|food,(\d+),(\d+)|g;

  print "Current resources: wood:$currwood clay:$currclay iron:$curriron food:$currfood   \r";
  $| = 1;
  sleep 10;

} while(($currwood<$wood) || ($currclay<$clay) || ($curriron < $iron) || ($currfood < $food));

print "\nDone!\n";