Welcome to the Monastery.

It would have been better to enclose your code snippet in "code" tags. Please read Writeup Formatting Tips. It's not too late to edit your post, deleting all "br" tags, and adding "code" tags around your code.

- what is the "2" in print "$host is dead\n" unless $p->ping($host, 2);?
According to the documentation for Net::Ping, the "2" is a timeout value:
$p->ping($host [, $timeout]);
Ping the remote host and wait for a response. $host can be either the hostname or the IP number of the remote host. The optional timeout must be greater than 0 seconds and defaults to whatever was specified when the ping object was created.
is there any shortcut way to put this in the @array?
I'm not sure what you mean by shortcut, but qw is handy for constructing arrays (note the absence of double quotes and commas):
my @array = qw(4.4.4.4 127.0.0.1 123.333.333.333);

Another general tip: add these to the top of your code:

use warnings; use strict;

I have no answer for your 1st question :(


In reply to Re: Net::Ping issues by toolic
in thread Net::Ping issues by chris_henderson

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.