Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 ================

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://945016]
help
Chatterbox?
[stevieb]: I'm learning that no matter how good a piece of software is at what it's supposed to do, it's a piece of shit without providing any API documentation. (Talking about C++ here currently). Seriously... write software for an embedded platform and make...
[stevieb]: ...you guess based on the sparse examples, and the header files that are spread out illogically?
[stevieb]: document the public facing functions/methods people... ALL OF THEM.

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2017-05-28 23:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?