Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
And let's say that the 12:34:00 in line 1, 12:35:02 in line 2, and 12:35:04 in line 3 represent time. I want to separate this column for each line and do a comparison to it, keeping hours, minutes and seconds separate. I am first thinking of doing a split to separate each line by commas and then go in to each line that matches a condition '987' (for example) and for each line with '987' I want to take the time and manipulate it. This is what I have so far:12345: 12:34:00,890,987,9876,... 12346: 12:35:02,789,987,234,... 12344: 12:35:04,345,987,1234,... etc.
How do I keep each field separate so that I can determine hours, minutes, and seconds?LINE: while (<THATFILE>) { next LINE if (!/^\d+: \d{2}:/ ); foreach $field(split /,/, $line) { chomp $field; if ($field == '987') { foreach $subtime (split /:/, $field) {
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: split into hash
by buckaduck (Chaplain) on Mar 20, 2001 at 04:02 UTC | |
|
Re: split into hash
by busunsl (Vicar) on Mar 20, 2001 at 04:04 UTC | |
|
Re: split into hash
by fpi (Monk) on Mar 20, 2001 at 04:04 UTC | |
|
Re: split into hash
by greenFox (Vicar) on Mar 20, 2001 at 08:06 UTC |