Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
No such thing as a small change
 
PerlMonks  

Re: Storing system grep's output to an array in perl

by arnaud99 (Beadle)
on Mar 07, 2013 at 11:52 UTC ( #1022216=note: print w/ replies, xml ) Need Help??


in reply to Storing system grep's output to an array in perl

Hi

A similar approach to the one above

use strict; use warnings; my @all_times; while (my $line = <DATA>) { if ($line =~ /^top - /) { chomp $line; my ($top, $dash, $time, @rest) = split /\s+/, $line; push @all_times, $time; } } for (@all_times) { print $_, "\n"; } __DATA__ top - 00:35:18 up... blah blah blah ..... top - 00:35:15 up... fwertwe blah blah blah ..... blah blah blah ..... blah blah blah ..... blah blah blah ..... blah blah blah ..... top - 00:35:20 up... blah blah blah ..... top - 00:35:22 up... blah blah blah ..... top - 00:35:30 up... blah blah blah .....

Output is:

00:35:18 00:35:15 00:35:20 00:35:22 00:35:30

Arnaud


Comment on Re: Storing system grep's output to an array in perl
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2014-04-24 00:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (557 votes), past polls