in reply to split into hash
Next, if you want to test only the 4th column for the '987' condition, you'll want to change your 'if' test to compare only the correct field.
After that, you could easily use a regex to grab the desired time components.
I'm also going to remove the unnecessary label and invert the logic of the 'next' conditional test, for readability only. I'm also going to remove the quotes from around '987' because I hate unnecessary quotes around numbers.
buckaduckwhile (<THATFILE>) { next unless (/^\d+: \d{2}:/ ); my @fields = split /,/; if ($fields[2] = 987) { my ($hour,$min,$sec) = /^\d+: (\d\d):(\d\d):(\d\d)/; ... } }
|
|---|