Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Sorry Laurent.Here below I am given my full code

#!/usr/bin/perl -w =head1 NAME ping_linux.pl - This script works on Linux system pings a host and re +turns statistics data. =head1 VERSION Version 1.0 =head1 AUTHOR Gaurav Dubey (gaurav.d@ronankiinfotech.com =head1 SYNOPSIS ./ping_linux.pl [-c --> count (Number of echo requests to be sent)] +[-i --> interval (Interval in milliseconds between echo requests)] [ +-s --> packetsize (Size of icmp packet)] [-h --> destinationIP (Ip ad +dress of destination host)] [-w --> AllowableTime (Max time in second +s for sending receiving echo requests/reponse)]" =head1 DESCRIPTION This pings a host via the system ping command and returns RTA ,Tx pack +ets,Rx packets,TTL,Packet-loss =cut use strict; use Getopt::Long; use Pod::Usage; my ($host,$count,$interval,$packetsize,$allowableTime); GetOptions( "h|host=s", \$host, "c|count=i", \$count, "i|interval=i", \$interval, "s|packetsize=i", \$packetsize, "w|allowableTime=i",\$allowableTime, ); #pod2usage("$0: No host given!\n") unless($host); pod2usage("$0:No host given!\n") unless($host && $host =~ /^((([2][5][ +0-5]|([2][0-4]|[1][0-9]|[0-9])?[0-9])\.){3})([2][5][0-5]|([2][0-4]|[1 +][0-9]|[0-9])?[0-9])$/); $count = 5 unless ($count); $interval = 1 unless ($interval); $packetsize = 56 unless ($packetsize); $allowableTime = 10 unless ($allowableTime); open CMD, "/bin/ping -c $count -i $interval -s $packetsize -w $allowab +leTime $host |" or die "Can't open ping: $!"; while (<CMD>) { my (@values1,@val1,@values2,@val2); if ( $_ =~ /PING/ ){ @values1 = split ; @val1 = split(/\(/,$values1[3]); $val1[1] =~ s/\)//; } print "$values1[1] \n"; print "$val1[0] \n"; if ($. == 2) { @values2 = split; @val2 = split(/\=/ , $values2[5]); } print "$val2[1] \n"; } close CMD

by this means I am running my perl script

./ping_linux.pl -h 74.125.235.7  -c 1

And this is my output

74.125.235.7 56 Use of uninitialized value $val2[1] in concatenation (.) or string at +./ping_linux.pl line 64, <CMD> line 1. Use of uninitialized value $values1[1] in concatenation (.) or string +at ./ping_linux.pl line 58, <CMD> line 2. Use of uninitialized value $val1[0] in concatenation (.) or string at +./ping_linux.pl line 59, <CMD> line 2. 54 Use of uninitialized value $values1[1] in concatenation (.) or string +at ./ping_linux.pl line 58, <CMD> line 3. Use of uninitialized value $val1[0] in concatenation (.) or string at +./ping_linux.pl line 59, <CMD> line 3. Use of uninitialized value $val2[1] in concatenation (.) or string at +./ping_linux.pl line 64, <CMD> line 3. Use of uninitialized value $values1[1] in concatenation (.) or string +at ./ping_linux.pl line 58, <CMD> line 4. Use of uninitialized value $val1[0] in concatenation (.) or string at +./ping_linux.pl line 59, <CMD> line 4. Use of uninitialized value $val2[1] in concatenation (.) or string at +./ping_linux.pl line 64, <CMD> line 4. Use of uninitialized value $values1[1] in concatenation (.) or string +at ./ping_linux.pl line 58, <CMD> line 5. Use of uninitialized value $val1[0] in concatenation (.) or string at +./ping_linux.pl line 59, <CMD> line 5. Use of uninitialized value $val2[1] in concatenation (.) or string at +./ping_linux.pl line 64, <CMD> line 5. Use of uninitialized value $values1[1] in concatenation (.) or string +at ./ping_linux.pl line 58, <CMD> line 6. Use of uninitialized value $val1[0] in concatenation (.) or string at +./ping_linux.pl line 59, <CMD> line 6. Use of uninitialized value $val2[1] in concatenation (.) or string at +./ping_linux.pl line 64, <CMD> line 6.

So now please enlighten me on this .Thanks


In reply to Re^2: uninitialized values by gaurav
in thread uninitialized values by gaurav

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



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-03-19 07:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found