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

styx-cc
 2006-12-10 18:10
#72451 #72451
User since
2006-05-20
533 Artikel
BenutzerIn

user image
Hmm... hab mich scheinbar zu frueh gefreut, jetzt klappts nicht mehr...

Der Code:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/perl -w
use strict;

use IO::Socket::INET;
use FileHandle;
use Encode;

#login data
my $nick = 'stefan@berlin';
my $pw = '12345';
my $channel = '12345';
my $SPIN; #socket
my $LOG; #filehandle

main_connection("Versuche einzuloggen..");

#### SUBS ####
sub main_connection {
my $text = shift;
print "$text\n\n";
$SPIN = shake_hands();
login();
&open_log();
#main
#while socket, hold it
my $line;
while (defined($line = <$SPIN>)) {
start($line);
}
main_connection("Versuche neu einzuloggen..") unless($line);
}

sub shake_hands {
my $host = 'www.hostname.com';
my $port = '0000';
#open the socket to chatserver
my $SPIN = IO::Socket::INET->new(

return $SPIN;
}

sub login {
#sending logindata to chatserver
}

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);

print $LOG $line or die $!; #klappt nicht
print $line; #klappt
}

sub open_log {
my $logfile = 'logfile2.txt';
$LOG = FileHandle->new(">>$logfile");
}

sub close_log {$LOG->close or die $!}

Vielleicht sieht ja wer noch was, ich versteht das immer noch nicht, jetzt schon gar nicht, wo er 3 Minuten gemacht hat was er soll und dann auf ein mal nicht mehr...

MfG
Pörl.

View full thread Filehandle globalisieren: aus sub heraus