perlpal has asked for the wisdom of the Perl Monks concerning the following question:
I am looking for a better way to perform the double split operation.
My requirement is to extract the date from the following table :
Timestamp 10.72.218.82:cpu_busy
-------------------------------------------------------------------------------
2009-11-05 17:59:52 1.501
The table is taken into a scalar variable.Hence, split is performed twice :
1: split on newline.
2: split on one or more spaces.
The code that i have written to achieve this seems to be very basic :
my @output = split(/\n/,$cmd_output); my @return_values = split(/\s+/,$output[-1]); my $date = $return_values[0];
Is there a better way to perform a double split operation?
Is there a better way to extract the date from the table?
Thanks in advance!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Better way to perform "double split" ?
by holli (Abbot) on Nov 10, 2009 at 09:02 UTC | |
|
Re: Better way to perform "double split" ?
by 7stud (Deacon) on Nov 10, 2009 at 09:17 UTC | |
by 7stud (Deacon) on Nov 10, 2009 at 09:37 UTC | |
by 7stud (Deacon) on Nov 10, 2009 at 09:48 UTC | |
|
Re: Better way to perform "double split" ?
by JavaFan (Canon) on Nov 10, 2009 at 10:51 UTC | |
|
Re: Better way to perform "double split" ?
by rovf (Priest) on Nov 10, 2009 at 09:36 UTC | |
by perlpal (Scribe) on Nov 10, 2009 at 10:15 UTC | |
by rovf (Priest) on Nov 10, 2009 at 11:21 UTC | |
|
Re: Better way to perform "double split" ?
by oha (Friar) on Nov 11, 2009 at 09:41 UTC |