>>>>> "CS" == Curt Shaffer <cshaf...@gmail.com> writes:

  Uri> post the output line from that command. do not let your emailer mung it
  >> or word wrap it. show the part you want to extract out. there may be
  >> easier ways to get it with a regex and not with split.

  CS> I think you may be right. I would like to pull the numerics out from the 
id= section. 

  CS> HPING www.microsoft.com (en1 207.46.19.190): S set, 40 headers + 0 data 
bytes
  CS> len=46 ip=207.46.19.190 ttl=64 DF id=21409 sport=80 flags=SA seq=0 
win=5840 rtt=102.8 ms

you did word wrap as i warned you not to. please be careful about
that. word wrapping means cutting/pasting your data to another program
will FAIL. you do not want to make it harder for people to help you.

that is easy to parse out (untested since i won't fix the word wrap):

my ( $ping_id ) = $hping =~ /\bid=(\d+)/ ;

regexes make that sort of data extraction so easy. your original awk on
fields now makes even less sense as it wasn't removing the id= part. awk
(and my split code) split on white space. looking for the id= part is
simpler and clearer (no counting of fields). and it is more robust as
the output line can add/delete fields (maybe based on options) and you
can still parse out id= and not count fields.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to