Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Unable to extract elements from a split. Kindly Help.

by Generoso (Parson)
on Dec 24, 2011 at 05:31 UTC ( #945016=note: print w/ replies, xml ) Need Help??


in reply to Unable to extract elements from a split. Kindly Help.

Since you do not say what is the expected result, my answer is guessing you want the element 3 from line 4.

Try this:

#!/usr/bin/perl use warnings; use strict; my @eachlinecmd = `ping 127.0.0.1`; my @eachwordcmd = split (/ /, $eachlinecmd[4]); print "@eachlinecmd\n"; print "@eachwordcmd\n"; print "$eachlinecmd[4]\n"; print "$eachwordcmd[3]\n";
perl "F:\perl_TK\perl1ping.pl" Process started >>> Pinging 127.0.0.1 with 32 bytes of data: Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 Ping statistics for 127.0.0.1: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 bytes=32 <<< Process finished. ================ READY ================


Comment on Re: Unable to extract elements from a split. Kindly Help.
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://945016]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (16)
As of 2015-07-29 12:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls