7 Einträge, 1 Seite |
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
#!/usr/bin/perl
use strict;
use warnings;
my $LOG;
open_log();
bla();
close_log();
sub open_log {
my $logfile = 'logfile.txt';
open LOG, '>>', $logfile or die("Can't open logfile: $!\n");
$LOG = *LOG;
}
sub bla {
fill_log();
}
sub fill_log {
print $LOG "$_\n" for (1..100);
}
sub close_log {
close $LOG or die $!;
}
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
#!/usr/bin/perl -w
use strict;
use IO::Socket::INET;
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();
$LOG = 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(
#socketdaten
return $SPIN;
}
sub login {
#sending logindata to chatserver
#serverlogin
}
sub start ($) {
my $line = shift;
#get first char, cause it means a affair wich happening, like op, deop, join and so on
my $cmd = substr($line, 0,1);
print $LOG "test\n";
}
sub open_log {
my $logfile = 'logfile2.txt';
open LOG, '>>', $logfile or die("Can't open logfile: $!\n");
return *LOG;
}
sub close_log {close $LOG or die $!}
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
#!/usr/bin/perl -w
use strict;
use IO::Socket::INET;
use Encode;
use FileHandle;
#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(
#socketdaten
return $SPIN;
}
sub login {
#sending logindata to chatserver
#serverlogin
}
sub start ($) {
my $line = shift;
#get first char, cause it means a affair wich happening, like op, deop, join and so on
my $cmd = substr($line, 0,1);
print $LOG "test\n";
}
sub open_log {
my $logfile = 'logfile2.txt';
$LOG = FileHandle->new(">>$logfile");
}
sub close_log {$LOG->close or die $!}
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 $!}
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;
}
7 Einträge, 1 Seite |