Created
August 21, 2011 21:48
-
-
Save olostan/1161218 to your computer and use it in GitHub Desktop.
Compensates tranes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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