# When I test the script locally in Windows, I need # to suppress flock because it's not supported # In use in the server, $flock is set to 1. my $flock = 1; sub modify { my $tmp_file = get_file(); open(FILE,"+<$tmp_file") || error("The file $tmp_file cannot be found!"); flock(FILE, 2) || die $! if $flock; chomp(my @lines = ); seek(FILE,0,0); truncate(FILE,0) || die $!; # could have used foreach here for (0..@lines) { my ($name, $score) = split/\|/, $lines[$_]; $score++; print FILE "$name|$score\n" if ($name); } close FILE; }