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

renee
 2006-12-10 17:37
#72449 #72449
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Arbeite mal mit CPAN:FileHandle:

(ungetestet)
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
#!/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 $!}
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Filehandle globalisieren: aus sub heraus