5 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
open(FH, ">$file") or die $!;
&lock(FH,2);
print FH $text;
&lock(FH,8);
close(FH);
sub lock{
flock($_[0],$_[1]);
}
1
2
3
4
5
6
7
8
9
use strict;
sub test {
local *FH = shift;
while (<FH>) {print;}
}
open FILE,'<',$0 or die $!;
test(*FILE);
close FILE;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use strict;
use warnings;
sub lock(*$){
flock($_[0],$_[1]);
}
my $file="foo";
my $text="hallo";
open(FH, ">$file") or die $!;
lock (FH,2);
print FH $text;
lock FH, 8;
close(FH);
5 Einträge, 1 Seite |