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":



  • 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.