Thread Filehandle globalisieren: aus sub heraus (6 answers)
Opened by styx-cc at 2006-12-10 16:49

styx-cc
 2006-12-10 21:52
#72454 #72454
User since
2006-05-20
533 Artikel
BenutzerIn

user image
Hab mein Buch "Netzwerkprogrammierung in Perl" ausgequetscht, so klappt es jetzt einwandfrei in Echtzeit :)
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
sub start ($) {
my $line = shift;
#get first char, cause it means an affair wich happening, like op, deop, join and so on
my $cmd = substr($line, 0,1);

flock($LOG, 'LOCK_EX');
print $LOG $line;
flock($LOG, 'LOCK_UN');

print $line;
}

sub open_log {
my $logfile = 'logfile2.txt';
$LOG = IO::File->
new($logfile,'0_WRONLY|0_APPEND|0_CREAT,0664') || return;
$LOG->autoflush(1); #das is wichtig!
return 1;
}


MfG und danke fuer die Hilfe :-)
Pörl.

View full thread Filehandle globalisieren: aus sub heraus