Skip to content

Instantly share code, notes, and snippets.

@olostan
Created August 21, 2011 21:48
Show Gist options
  • Save olostan/1161218 to your computer and use it in GitHub Desktop.
Save olostan/1161218 to your computer and use it in GitHub Desktop.
Compensates tranes
sub readfile
{
my $fn = shift;
local $/=undef;
open FILE, $fn or die "Couldn't open file: $!";
$string = <FILE>;
close FILE;
return $string;
}
sub writefile {
my ($fn,$data) = @_;
open FILE, ">$fn" or die "Couldn't write file";
print FILE $data;
close FILE;
}
open (COMP, 'compenation.csv') || die('cant open file');
while(<COMP>) {
my ($name, $tra) = split(/,/);
$tra +=0; # autochomp
print "Changing profile of $name (Adding $tra trains)\n";
my $content = readfile('player/'.$name);
$content =~ s/Trai (\d+)/"Trai "+($1+$tra)/ge;
writefile('player/'.$name.'.bak', $content);
}
close COMP;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment