Can not get following code work.
It works only when recive the first line.
Any ideas??
Regards.
Leandro.
#!/usr/bin/perl -slw use strict; use Regexp::Common qw/ net number /; use IO::Socket::INET::Daemon; use Parallel::ForkManager; use Net::Ping; use DBI; use YAML::Tiny; ###################################################################### +################## my $pm = Parallel::ForkManager->new(10); my $host = new IO::Socket::INET::Daemon( host => 'localhost', port => 1000, timeout => 20, callback => { data => \&data, }, ); $host->run; sub data{ my ($io, $host) = @_; my $line = $io->getline; return 0 unless $line; chomp($line); if($line =~ m/$RE{net}{IPv4}{-keep}/){ print "I got ip $1\n"; my $pid = $pm->start and next ; fork_work($1); $pm->finish; # Terminates the child process return !0; } print "not a good line:",$line; return !0; } $pm->wait_all_children; ###################################################################### +################## sub fork_work { print "working from new child!!!" }
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |