in reply to Array Problem

initial reaction is that Net::Ping maybe be helpful to avoid the external creation of ping.txt.. Also, i would suggest adding use strict; and use warnings; ... to debug your problem of 0 alive and 0 dead, i would put a debugging print statement in the while(@results){} loop to see what it's doing.. it's probably not matching on /Reply/ or Request so first step is to look at what string it's searching.. can you show us a snippet from ping.txt?

quick side note: foreach my $j ( 1 .. 255 ){} is a more "Perl-ish" way to write that first loop.

Replies are listed 'Best First'.
Re^2: Array Problem
by wanderinweezard (Initiate) on Jul 08, 2005 at 15:21 UTC
    Thanks for the perl style advice, I'll make sure to change that. Here is a snippet of the ping.txt. I am also looking into Net::Ping, but am not sure how to install it in a Win32 environment.
    
    
    Reply from 10.0.5.1: bytes=32 time<1ms TTL=255
    
    
    
    
    Request timed out.
    
    
    
    
    Reply from 10.0.5.3: bytes=32 time<1ms TTL=128
    
    
    
    
    Reply from 10.0.5.4: bytes=32 time<1ms TTL=128
    
    
    
    
    Reply from 10.0.5.5: bytes=32 time<1ms TTL=255
    
    
    
    
    Reply from 10.0.5.6: bytes=32 time<1ms TTL=128
    
    
    Yes, those are spaced like that in the actual file.
      There's good stuff in the Tutorials on installing modules (and specifically in Win32 with ppm)

      the spaces should be fine with those regex checks you had.. after seeing the other posts i too think it was the cloberring of ping.txt that made it appear to have no data.. A debugging print statement in there by the regex check may still be a good idea (if in there orginally, it would have pointed in the direction of the clobbering because you'd see that the print wasn't being reached).

      What Perl installation do you have on your Windows box? If you're using ActiveState, do the following to install a module:

      1. Open a DOS prompt.
      2. Change directories to the location where you installed Perl.
      3. Change into the bin subdirectory of your Perl installation.
      4. Type ppm at the prompt.

      This runs the ppm.bat batch file and opens an interactive PPM session. (You can tell you're in a PPM session because the prompt is ppm>.) Type help to get a listing of commands. In the case of Net::Ping, type:

      search Net-Ping

      and press Enter. PPM will search ActiveState repositories for the module and return a numbered listing of its findings. For example:

      ppm> search Net-Ping Searching in Active Repositories 1. Net-Ping-External [0.11] Cross-platform interface to ICMP "ping" +utilities ppm>

      To install one of the listed modules, simply type the install command along with the name, or number, of the desired package, like so:

      ppm> install 1 or ppm> install Net-Ping-External

      PPM will fetch and install the module and write a series of messages to the screen. When it completes, it returns to the PPM prompt. Type q to quit the PPM session.

      PPM will make your module-installing life much easier under Windows. :)

      I hope this helps.

      /Larry