Re: Is this one line out of date (circa 2002)
Rob Dixon rob.di...@gmx.com writes: And then (trying to print just the time column perl -i -n -a -e 'print @F[6];' ping.lst But there is no output at all. The -i option calls for in-place editing, where the output from Perl replaces the input file. Take a look at ping.lst and you should find your output. If you want to see the output on the console, just remove -i and, if you would prefer to see each item on a separate line, add -l like this perl -l -n -a -e 'print @F[6]' ping.lst Egad, that was a dimwitted oversight about -i. Thanks, that small script shows a nice way to make use of perl similarly and as handy as awk. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: looping through an array with for
Thank you Jim. Your suggestions worked perfectly! -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: looping through an array with for
Hi Jim, Well, instead of asking at each step, whether the last element is processed or not, it's slightly better to exclude it from the loop: for my $i (0..$#keyFields - 1) { printf %s %s, $keyFields[$i], $match; } printf %s %s, $keyFields[-1], $lastmatch; But yes, I guess your last approach is just what the doctor ordered in this case. ) I'd use a map, though: print join ' AND ', map { $_ GE 0 } @keyFields; .. as, again, it'd be slightly more efficient to allocate the space for the resulting array just once. -- iD 2012/2/15 Jim Gibson jimsgib...@gmail.com At 9:08 PM -0700 2/14/12, Chris Stinemetz wrote: I have a for loop I would like to alter so that when the iteration reaches the last element in the array the varibale $lastmatch is passed to printf instead of $match. Does anyone have any suggestions? my $match = GE 0 AND ; my $lastmatch = GE 0; for my $i (0 .. $#keyFields) { printf %s %s, $keyFields[$i], $match,; } There are several approaches: 1. for my $i (0 .. $#keyFields) { printf %s %s, $keyFields[$i], ($i$#keyFields?$match:$**lastmatch); } 2. for my $i (0 .. $#keyFields) { if( $i == $#keyFields ) { printf %s %s, $keyFields[$i], $lastmatch; }else{ printf %s %s, $keyFields[$i], $match; } } 3. my @output; for my $field (@keyFields) { push( @output, sprintf(%s GE O ,$field); } print join(AND,@output); -- Jim Gibson j...@gibson.org -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Module error
Hi, I am running my perl script and using some perl modules like below :- use File::Path qw(mkpath); use File::Rsync; my $rsync = '/opt/zimbra/rsync/bin/rsync'; when I run the script using perl scriptname -- then it runs fine, however when I run through crontab, it get this error : - Can't locate File/Rsync.pm in @INC (@INC contains:/etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl .) at /opt/zimbra/lbin/backup.pl line 8. Any clues ? Best Regards. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Module error
I am running my perl script and using some perl modules like below :- use File::Path qw(mkpath); use File::Rsync; my $rsync = '/opt/zimbra/rsync/bin/rsync'; when I run the script using perl scriptname -- then it runs fine, however when I run through crontab, it get this error : - Can't locate File/Rsync.pm in @INC (@INC contains:/etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl .) at /opt/zimbra/lbin/backup.pl (http://backup.pl) line 8. Any clues ? Most likely, the perl binary you're using is not the same one your cron is using. Do 'which perl' in your shell, and then use the full path to that binary in your cron entry, and see if that doesn't fix it. If it doesn't, then there's some other aspect of your interactive environment (PERL5LIB, etc.) that isn't set in the crontab environment. chrs, john.
Re: Module error
On 2/15/12 Wed Feb 15, 2012 10:13 AM, Punit Jain contactpunitj...@gmail.com scribbled: Hi, I am running my perl script and using some perl modules like below :- use File::Path qw(mkpath); use File::Rsync; my $rsync = '/opt/zimbra/rsync/bin/rsync'; when I run the script using perl scriptname -- then it runs fine, however when I run through crontab, it get this error : - Can't locate File/Rsync.pm in @INC (@INC contains:/etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl .) at /opt/zimbra/lbin/backup.pl line 8. Any clues ? One problem with executing programs using cron is that cron does not execute your login scripts that setup and customize your interactive session, such as .profile, .login, .bashrc, or .cshrc, depending upon your shell. Do you use any environment variables such as PERL5LIB? Those will not be set. Where is the module File::Rsync located? Type 'perldoc -l File::Rsync' to find out. One workaround is to have cron execute a shell script that sources your login scripts and then executes your Perl program, something like: #!/bin/tcsh # source ~user/.login source ~user/.cshrc perl scriptname (I use tcsh, so the above may not be correct for your shell) -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Module error
Hello Jim, On Wed, 15 Feb 2012 10:28:23 -0800 Jim Gibson jimsgib...@gmail.com wrote: On 2/15/12 Wed Feb 15, 2012 10:13 AM, Punit Jain contactpunitj...@gmail.com scribbled: Hi, I am running my perl script and using some perl modules like below :- use File::Path qw(mkpath); use File::Rsync; my $rsync = '/opt/zimbra/rsync/bin/rsync'; when I run the script using perl scriptname -- then it runs fine, however when I run through crontab, it get this error : - Can't locate File/Rsync.pm in @INC (@INC contains:/etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl .) at /opt/zimbra/lbin/backup.pl line 8. Any clues ? One problem with executing programs using cron is that cron does not execute your login scripts that setup and customize your interactive session, such as .profile, .login, .bashrc, or .cshrc, depending upon your shell. Do you use any environment variables such as PERL5LIB? Those will not be set. Where is the module File::Rsync located? Type 'perldoc -l File::Rsync' to find out. One workaround is to have cron execute a shell script that sources your login scripts and then executes your Perl program, something like: #!/bin/tcsh # source ~user/.login source ~user/.cshrc perl scriptname (I use tcsh, so the above may not be correct for your shell) at the risk of starting a flame-war, you should not encourage people to write their scripts in C-shell (not that using it as a login shell is too recommended either), because it is a braindead shell with poorly designed semantics. See: http://www.shlomifish.org/open-source/anti/csh/ I refer there to Csh programming considered harmful by Tom Christiansen (who authored large parts of Perl's documentation) to a continuation document by Bruce Barnett and give some other compelling reasons of my own. Regards, Shlomi Fish -- - Shlomi Fish http://www.shlomifish.org/ Interview with Ben Collins-Sussman - http://shlom.in/sussman rindolf buu: do you have a functional spec? An architecture document? An interface whitepaper? A developer’s guide? A user manual? A “The BL Book” and “BL — The Program”? buu rindolf: no, no, no no and no Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Module error
On 2/15/12 Wed Feb 15, 2012 10:56 AM, Shlomi Fish shlo...@shlomifish.org scribbled: at the risk of starting a flame-war, you should not encourage people to write their scripts in C-shell (not that using it as a login shell is too recommended either), because it is a braindead shell with poorly designed semantics. See: http://www.shlomifish.org/open-source/anti/csh/ I refer there to Csh programming considered harmful by Tom Christiansen (who authored large parts of Perl's documentation) to a continuation document by Bruce Barnett and give some other compelling reasons of my own. Sorry, Shlomi, but I disagree with you. I am not encouraging people to write scripts in csh, just giving an example in the shell script with which I am familiar (tcsh). I have read the references to which you refer, and do not agree with them. Most of the disadvantages they ascribe to csh only come into play if the scripts are quite complicated. At that level of complication, I naturally use Perl! I have written and will continue to write scripts in csh and tcsh because they work for me and do what I want. People should use the tools that work for them. They should also be aware of the shortcomings of any tool they are using, and I am. All of that said, a Perl beginners list is not the place to discuss shell programming. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Fwd: XML QUERY
Hi List , I have two files one is a csv file another is a XML files which are given here as attachments. Now I need to create a XML(Which is given here) file from this CSV file(Also here as an attachment) and Create a CSV file from this XML file. My question is what perl module or modules I need two use for these two tasks. The actual CSV file and XML files both are is very large in size thats why I am providing some lines for this file. Best Regards Anirban Adhikary. !BSC,Species,Path,Name,Mark,Comment,timeStamp.emg.date,timeStamp.emg.time,timeStamp.tg.date,timeStamp.tg.time,timeStamp.ru.date,timeStamp.ru.time,timeStamp.cell.date,timeStamp.cell.time,scgrss.sclists.sc,scgrss.sclists.scdev,scgrss.sclists.scdev1,scgrss.sclists.dcp,scgrss.sclists.numdev,infosource,bsc,type,version,optionalFeatures.name,optionalFeatures.value,nrmDn,scgrss.scgr,scgrss.mode,scgrss.pstuname,scgrss.mbwdl,scgrss.mbwul,scgrss.jbsul,scgrss.ldel,scgrss.ipov,stns.stnname,stns.stnversion,stns.stntype,stns.stnfdn,pstus.pstuname,pstus.stnname,pstus.inBsc,concboardalarm,concboardcease,conclinkalarm,conclinkcease,defaultsyncsrc,exmasterres,fcmaxnoptglg01,fcmaxnoptglg12,fcmaxnoptgug12,mccsupport,numtraloads,rectime,reccap,regpointprocld,tfoconfigtra,tfostatus,tphstatus,tradroplevel,trxtautoinitime,trxtautothrshld,tslooptest,ttalong,ttanormal 1,BSC,subnetwork=NETSimG,0306,NULL,NULL,20111201,214059,20111201,213700,20111201,213700,20111201,213625,NULL,NULL,NULL,NULL,NULL,onrm,0306,AXE,G11B,ABISIP,1,SubNetwork=ONRM_ROOT_MO,SubNetwork=NETSimG,ManagedElement=0306,BssFunction=BSS_ManagedFunction,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,70,60,70,60,65535,0,0,0,0,0,3,0,10,80,0,0,0,0,10,20,1,15,10 1,BSC,subnetwork=NETSimG,0306,NULL,NULL,20111201,214059,20111201,213700,20111201,213700,20111201,213625,NULL,NULL,NULL,NULL,NULL,onrm,0306,AXE,G11B,ABISOPT,1,SubNetwork=ONRM_ROOT_MO,SubNetwork=NETSimG,ManagedElement=0306,BssFunction=BSS_ManagedFunction,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,70,60,70,60,65535,0,0,0,0,0,3,0,10,80,0,0,0,0,10,20,1,15,10 1,BSC,subnetwork=NETSimG,0306,NULL,NULL,20111201,214059,20111201,213700,20111201,213700,20111201,213625,NULL,NULL,NULL,NULL,NULL,onrm,0306,AXE,G11B,ACAISGRET,1,SubNetwork=ONRM_ROOT_MO,SubNetwork=NETSimG,ManagedElement=0306,BssFunction=BSS_ManagedFunction,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,70,60,70,60,65535,0,0,0,0,0,3,0,10,80,0,0,0,0,10,20,1,15,10 1,BSC,subnetwork=NETSimG,0306,NULL,NULL,20111201,214059,20111201,213700,20111201,213700,20111201,213625,NULL,NULL,NULL,NULL,NULL,onrm,0306,AXE,G11B,ACAISGTMA,1,SubNetwork=ONRM_ROOT_MO,SubNetwork=NETSimG,ManagedElement=0306,BssFunction=BSS_ManagedFunction,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,70,60,70,60,65535,0,0,0,0,0,3,0,10,80,0,0,0,0,10,20,1,15,10 1,BSC,subnetwork=NETSimG,0306,NULL,NULL,20111201,214059,20111201,213700,20111201,213700,20111201,213625,NULL,NULL,NULL,NULL,NULL,onrm,0306,AXE,G11B,ACCSTMA,1,SubNetwork=ONRM_ROOT_MO,SubNetwork=NETSimG,ManagedElement=0306,BssFunction=BSS_ManagedFunction,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,70,60,70,60,65535,0,0,0,0,0,3,0,10,80,0,0,0,0,10,20,1,15,10 1,BSC,subnetwork=NETSimG,0306,NULL,NULL,20111201,214059,20111201,213700,20111201,213700,20111201,213625,NULL,NULL,NULL,NULL,NULL,onrm,0306,AXE,G11B,AOIP,0,SubNetwork=ONRM_ROOT_MO,SubNetwork=NETSimG,ManagedElement=0306,BssFunction=BSS_ManagedFunction,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,70,60,70,60,65535,0,0,0,0,0,3,0,10,80,0,0,0,0,10,20,1,15,10 1,BSC,subnetwork=NETSimG,0306,NULL,NULL,20111201,214059,20111201,213700,20111201,213700,20111201,213625,NULL,NULL,NULL,NULL,NULL,onrm,0306,AXE,G11B,ATHAABIS,0,SubNetwork=ONRM_ROOT_MO,SubNetwork=NETSimG,ManagedElement=0306,BssFunction=BSS_ManagedFunction,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,70,60,70,60,65535,0,0,0,0,0,3,0,10,80,0,0,0,0,10,20,1,15,10 1,BSC,subnetwork=NETSimG,0306,NULL,NULL,20111201,214059,20111201,213700,20111201,213700,20111201,213625,NULL,NULL,NULL,NULL,NULL,onrm,0306,AXE,G11B,AUTOFLP,1,SubNetwork=ONRM_ROOT_MO,SubNetwork=NETSimG,ManagedElement=0306,BssFunction=BSS_ManagedFunction,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,70,60,70,60,65535,0,0,0,0,0,3,0,10,80,0,0,0,0,10,20,1,15,10 1,BSC,subnetwork=NETSimG,0306,NULL,NULL,20111201,214059,20111201,213700,20111201,213700,20111201,213625,NULL,NULL,NULL,NULL,NULL,onrm,0306,AXE,G11B,AUTOHFSEXPAND,1,SubNetwork=ONRM_ROOT_MO,SubNetwork=NETSimG,ManagedElement=0306,BssFunction=BSS_ManagedFunction,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,70,60,70,60,65535,0,0,0,0,0,3,0,10,80,0,0,0,0,10,20,1,15,10 ?xml version=1.0 encoding=UTF-8? BSM id=bsm xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
Re: Module error
On 12-02-15 01:13 PM, Punit Jain wrote: Hi, I am running my perl script and using some perl modules like below :- use File::Path qw(mkpath); use File::Rsync; my $rsync = '/opt/zimbra/rsync/bin/rsync'; when I run the script using perl scriptname -- then it runs fine, however when I run through crontab, it get this error : - Can't locate File/Rsync.pm in @INC (@INC contains:/etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl .) at /opt/zimbra/lbin/backup.pl line 8. Any clues ? Best Regards. Are you running perlbrew? -- Just my 0.0002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding. It's Mutual Aid, not fierce competition, that's the dominate force of evolution. Of course, anyone who has worked in open source already knows this. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
research for secure tchat client server use IO::Socket::SSL
hi guys hi master of Fu any update I am doing some research on the server and client for the chat. I have long taken the trouble to consult the documentation that is different and both PerlMonks different pages that deal with this vast subject. I try to find a minimal example because I want to turn into non securise securise. here is the status of my research #!/usr/bin/perl use warnings; use strict; use IO::Socket::SSL 'inet4'; use threads; use threads::shared; $|++; print $$ Server started\n; # do a top -p -H $$ to monitor server ++ threads our @clients : shared; @clients = (); my $server = new IO::Socket::SSL( Timeout = 7200, Proto = tcp, LocalPort = 42000, Reuse = 1, Listen= 3, SSL_use_cert = 1, SSL_verify_mode = 0x00, SSL_key_file= '/home/swilting/perltest/private/localhost.key' +, SSL_cert_file = '/home/swilting/perltest/certs/localhost.cert', SSL_passwd_cb = sub { return }, ); my $num_of_client = -1; while (1) { my $client; do { $client = $server-accept; } until ( defined($client) ); my $peerhost = $client-peerhost(); print accepted a client $client, $peerhost, id = , ++$num_of_client, \n; my $fileno = fileno $client; push (@clients, $fileno); #spawn a thread here for each client my $thr = threads-new( \processit, $client, $fileno, $peerhost ) +-detach(); } # end of main thread sub processit { my ($lclient,$lfileno,$lpeer) = @_; #local client if($lclient-connected){ # Here you can do your stuff # I use have the server talk to the client # via print $client and while($lclient) print $lclient $lpeer-Welcome to server\n; while($lclient){ # print $lclient $lpeer-$_\n; print clients- @clients\n; foreach my $fn (@clients) { open my $fh, =$fn or warn $! and die; print $fh $lpeer-$_ } } } #close filehandle before detached thread dies out close( $lclient); #remove multi-echo-clients from echo list @clients = grep {$_ !~ $lfileno} @clients; } __END__ #!/usr/bin/perl use warnings; use strict; use Tk; use IO::Socket::SSL 'inet4'; require Tk::ROText; #get id my $name = shift || 'anon'; # create the socket my $host = 'localhost'; my $port = 42000; my $socket = IO::Socket::SSL-new( PeerAddr = $host, PeerPort = $port, Proto= 'tcp', SSL_use_cert = 1, SSL_verify_mode = 0x00, SSL_key_file= '/home/swilting/perltest/private/localhost.k +ey', SSL_cert_file = '/home/swilting/perltest/certs/localhost.cer +t', SSL_passwd_cb = sub { return }, ); defined $socket or die ERROR: Can't connect to port $port on $host: $ +!\n; print STDERR Connected to server ...\n; my $mw = new MainWindow; my $log = $mw-Scrolled('ROText', -scrollbars='ose', -height= 5, -width=45, -background = 'lightyellow', )-pack; my $txt = $mw-Entry( -background='white', )-pack(-fill= 'x', -pady= 5); $mw -bind('Any-Enter' = sub { $txt-Tk::focus }); $txt-bind('Return' = [\broadcast, $socket]); $mw -fileevent($socket, readable = sub { my $line = $socket; unless (defined $line) { $mw-fileevent($socket = readable = ''); return; } $log-insert(end = $line); $log-see('end'); }); MainLoop; sub broadcast { my ($ent, $sock) = @_; my $text = $ent-get; $ent-delete(qw/0 end/); print $sock $name.'-'. $text, \n; } __END__ #Server.pl #!/usr/local/bin/perl use strict; use warnings; use IO::Socket::SSL 'inet4'; my $server = IO::Socket::SSL-new( LocalPort= 42000, ## Type=SOCK_STREAM, Reuse=1, Listen=5, Proto= 'tcp', SSL_use_cert = 1, SSL_verify_mode = 0x00, SSL_key_file= '/home/swilting/perltest/private/localhost.key', SSL_cert_file = '/home/swilting/perltest/certs/localhost.cert', SSL_passwd_cb = sub { return }, )or die (Could not create server); while(my $client=$server-accept()){ my $child_pid; unless(defined ($child_pid=fork())){diecan not fork\n;} if(defined($child_pid)){ while(my $line = $client){ print CLIENT says:$line\n; } } else{ while(my $line = ){ print $client $line\n; } } } redo; close($server); ; the server running the threads fails with a segmentation fault and my client fails after two requests I do not know why and characters displayed on the client encodes are poorly I do not know either why -- http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC2626742 gpg --keyserver pgp.mit.edu --recv-key C2626742 http://urlshort.eu fakessh @ http://gplus.to/sshfake http://gplus.to/sshswilting http://gplus.to/john.swilting https://lists.fakessh.eu/mailman/ This list is moderated by me, but all applications will be accepted provided they receive a note of presentation signature.asc Description: Ceci est une partie de message numériquement signée
Re: research for secure tchat client server use IO::Socket::SSL
forgiveness for the bad presentation perl code see my post on PerlMonks http://www.perlmonks.org/?node_id=954050 Le 2012-02-15 20:51, ml a écrit : hi guys hi master of Fu any update I am doing some research on the server and client for the chat. I have long taken the trouble to consult the documentation that is different and both PerlMonks different pages that deal with this vast subject. I try to find a minimal example because I want to turn into non securise securise. here is the status of my research #!/usr/bin/perl use warnings; use strict; use IO::Socket::SSL 'inet4'; use threads; use threads::shared; $|++; print $$ Server started\n; # do a top -p -H $$ to monitor server ++ threads our @clients : shared; @clients = (); my $server = new IO::Socket::SSL( Timeout = 7200, Proto = tcp, LocalPort = 42000, Reuse = 1, Listen= 3, SSL_use_cert = 1, SSL_verify_mode = 0x00, SSL_key_file= '/home/swilting/perltest/private/localhost.key' +, SSL_cert_file = '/home/swilting/perltest/certs/localhost.cert', SSL_passwd_cb = sub { return }, ); my $num_of_client = -1; while (1) { my $client; do { $client = $server-accept; } until ( defined($client) ); my $peerhost = $client-peerhost(); print accepted a client $client, $peerhost, id = , ++$num_of_client, \n; my $fileno = fileno $client; push (@clients, $fileno); #spawn a thread here for each client my $thr = threads-new( \processit, $client, $fileno, $peerhost ) +-detach(); } # end of main thread sub processit { my ($lclient,$lfileno,$lpeer) = @_; #local client if($lclient-connected){ # Here you can do your stuff # I use have the server talk to the client # via print $client and while($lclient) print $lclient $lpeer-Welcome to server\n; while($lclient){ # print $lclient $lpeer-$_\n; print clients- @clients\n; foreach my $fn (@clients) { open my $fh, =$fn or warn $! and die; print $fh $lpeer-$_ } } } #close filehandle before detached thread dies out close( $lclient); #remove multi-echo-clients from echo list @clients = grep {$_ !~ $lfileno} @clients; } __END__ #!/usr/bin/perl use warnings; use strict; use Tk; use IO::Socket::SSL 'inet4'; require Tk::ROText; #get id my $name = shift || 'anon'; # create the socket my $host = 'localhost'; my $port = 42000; my $socket = IO::Socket::SSL-new( PeerAddr = $host, PeerPort = $port, Proto= 'tcp', SSL_use_cert = 1, SSL_verify_mode = 0x00, SSL_key_file= '/home/swilting/perltest/private/localhost.k +ey', SSL_cert_file = '/home/swilting/perltest/certs/localhost.cer +t', SSL_passwd_cb = sub { return }, ); defined $socket or die ERROR: Can't connect to port $port on $host: $ +!\n; print STDERR Connected to server ...\n; my $mw = new MainWindow; my $log = $mw-Scrolled('ROText', -scrollbars='ose', -height= 5, -width=45, -background = 'lightyellow', )-pack; my $txt = $mw-Entry( -background='white', )-pack(-fill= 'x', -pady= 5); $mw -bind('Any-Enter' = sub { $txt-Tk::focus }); $txt-bind('Return' = [\broadcast, $socket]); $mw -fileevent($socket, readable = sub { my $line = $socket; unless (defined $line) { $mw-fileevent($socket = readable = ''); return; } $log-insert(end = $line); $log-see('end'); }); MainLoop; sub broadcast { my ($ent, $sock) = @_; my $text = $ent-get; $ent-delete(qw/0 end/); print $sock $name.'-'. $text, \n; } __END__ #Server.pl #!/usr/local/bin/perl use strict; use warnings; use IO::Socket::SSL 'inet4'; my $server = IO::Socket::SSL-new( LocalPort= 42000, ## Type=SOCK_STREAM, Reuse=1, Listen=5, Proto= 'tcp', SSL_use_cert = 1, SSL_verify_mode = 0x00, SSL_key_file= '/home/swilting/perltest/private/localhost.key', SSL_cert_file = '/home/swilting/perltest/certs/localhost.cert', SSL_passwd_cb = sub { return }, )or die (Could not create server); while(my $client=$server-accept()){ my $child_pid; unless(defined ($child_pid=fork())){diecan not fork\n;} if(defined($child_pid)){ while(my $line = $client){ print CLIENT says:$line\n; } } else{ while(my $line = ){ print $client $line\n; } } } redo; close($server); ; the server running the threads fails with a segmentation fault and my client fails after two requests I do not know why and characters displayed on the client encodes are poorly I do not know either why -- http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC2626742 gpg --keyserver pgp.mit.edu --recv-key C2626742 http://urlshort.eu fakessh @ http://gplus.to/sshfake http://gplus.to/sshswilting http://gplus.to/john.swilting https://lists.fakessh.eu/mailman/ This list is moderated by me, but all applications will be accepted provided they receive a note of presentation -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/