[Israel.pm] Why am I not printing getting results? What am Imissing
Levenglick Dov-RM07994
dov at freescale.com
Tue Sep 18 05:21:00 PDT 2007
This worked. Why can't I eliminate the $tmp in the subroutine?
use strict;
use warnings;
use Net::Ping;
use threads;
my $num_pings = 10;
my $host = "223.31.95.254";
my $errors = 0;
map {threads->create(\&single_ping, $host)} (1..$num_pings);
map {$errors++ unless $_->join()} (threads->list());
exit $errors;
sub single_ping
{
my $p = Net::Ping->new();
my $tmp = $p->ping(shift);
return $tmp;
}
Best Regards,
Dov Levenglick
SmartDSP OS Development Team,
DevTech, Technology and System Organization
Freescale Semiconductor Israel
Tel. +972-9-952-2804
The information contained in this email is classified as:
[ ] Freescale General Business Information
[ ] Freescale Internal Use Only
[ ] Freescale Confidential Proprietary
[x] Personal Memorandum
-----Original Message-----
From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] On
Behalf Of Chanan Berler
Sent: Tuesday, September 18, 2007 14:08
To: Perl in Israel
Subject: Re: [Israel.pm] Why am I not printing getting results? What am
Imissing
try this first:
use strict;
use warnings;
use Net::Ping;
my $p = Net::Ping->new();
return $p->ping(223.31.95.254);
check if it works....then apply the thread stuff.
Also i think the shift is misplaced...i think you should use the $_
in the subroutine, since i can't tell if it not changed when using
my $p = Net::Ping->new();
also did you try apply a simple ping from command line - see if it works
Chanan
On 9/18/07, Levenglick Dov-RM07994 <dov at freescale.com> wrote:
> use strict;
> use warnings;
>
> use Net::Ping;
> use threads;
>
> my $num_pings = 10;
> my $host = "223.31.95.254";
>
> threads->create(\&single_ping, $host) for (1..$num_pings);
> map {print $_, $_->join(), "\n"} threads->list();
>
> sub single_ping
> {
> my $p = Net::Ping->new();
> return $p->ping(shift);
> }
>
>
> Best Regards,
> Dov Levenglick
> SmartDSP OS Development Team,
> DevTech, Technology and System Organization
> Freescale Semiconductor Israel
> Tel. +972-9-952-2804
> The information contained in this email is classified as:
> [ ] Freescale General Business Information
> [ ] Freescale Internal Use Only
> [ ] Freescale Confidential Proprietary
> [x] Personal Memorandum
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl
>
--
===================
---- Chanan Berler ----
===================
_______________________________________________
Perl mailing list
Perl at perl.org.il
http://perl.org.il/mailman/listinfo/perl
More information about the Perl
mailing list