in reply to Getting the text I want

I would break each of your ping strings up via split'ing on newlines, as a starting point. Within each new array, first grep out only those that start with "Reply" into a second array. Then, assuming that the average will always be in the last one, you can grab that portion from the last element of the split.

Something like the following:

my @pings = split /\n/, $ping; my @keep = grep { /^Reply/ } @pings; $pings[-1] =~ /(Average =.+)$/ ); my $avg = $1; push @keep, $avg; print join '\n', @keep;
Other transformations are then rather trivial.

-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
It's not what you know, but knowing how to find it if you don't know that's important

Replies are listed 'Best First'.
Re: Re: Getting the text I want
by Hofmator (Curate) on Aug 21, 2001 at 18:45 UTC

    I would break each of your ping strings up via split'ing on newlines, as a starting point.
    Isn't it easier in this case to use an array directly to get the output from the backticks? my @ping1 = `ping some.one.org`;

    -- Hofmator