open (my $fh, "+<$area_status_file") or die "Can't open $area_status_file due to ![]() $area = undef; # synchronized access to the area file for multiple processes my @areas; while(<$fh>) { chomp; push @areas, $_; } for(my $i = 0; $i < scalar(@areas); $i ++ ) { ($break, $area, $new_line) = $coderef->($areas[$i]); do { $areas[$i] = $new_line; last; } if $break; } #reposition the pointer to start of file after copying seek($fh, 0, SEEK_SET); foreach my $line (@areas) { print $fh "$line\n"; } close $fh; |
歡迎光臨 Chinaunix (http://www.72891.cn/) | Powered by Discuz! X3.2 |