Dear BrowserUk , the script is almost done, After applying both changes it begun working, but there is something wrong when the walker receives the line from the listener, it receives only a number instead of the complete line.
I put them to print as following:
sub listener {
my( $Qout ) = @_;
require IO::Socket::INET::Daemon; ## Requiring here means other
+threads don't carry the redundant weight
my $host = new IO::Socket::INET::Daemon(
host => '172.24.3.208', port => 7777, timeout => 20,
callback => { data =>
sub {
my ($io, $host) = @_;
chomp( my $line = <$io> );
return 0 unless $line;
print "here line is : $line";
$Qout->enqueue( $line ); ## send work to listener
return !0;
}
},
);
$host->run;
return;
}
sub walker {
my( $Qin, $Qout ) = @_;
while( $Qin->dequeue ) { ## receive work from listener
print "here \$\_ is : $_";
my( $type, $ip, $mac, $bsid, $datecode ) = split( ',', $_ );
$mac =~ tr[-][]d;
and got the following:
here line is : 2,190.115.32.180,00-21-07-2E-DD-6A,000044000070,20160426105156,D
here $_ is : 7
Use of uninitialized value in transliteration (tr///) at ./lines_dispacher_and_consumer_threads.pl line 34.
Use of uninitialized value $ip
....
...
..
.
Im reading the Thread::Queue documentacion and the example provided looks very similar like your method ... I will keep investigating it.
Thanks
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.