Man! You gotta clean up this post! (as noted by previous posters)
That aside:
- I would use a regex to find /^(Monday||Tuesday||Wednesday||Thursday||Friday||Saturday||Sunday).?UTC\s\d\d\d\d\s$/(which I assume is constant for the beginning of each record, perhaps wrongly assumed). Maybe keep track of the fact that you have found the first one, because you will do that same search subsequently
- Execute same search again capturing the pre-match ($`) and the match ($&).
- Process the pre-match by finding each /\:\s\d+\s$/, which is probably your value, with your pre-match being the key and shoving key/values into a hash.
- Ouput your 'Date" and your keys to the first line of the CSV file(only have to do this once), giving you your header row.
- Output your first match and your values to the second row, giving you your first record
- Repeat 2 - 5 using the previous match as the first field in the record each time and the values from your hash generated by the processed pre-match as the rest of the fields. (sounds like a subroutine to me)
This assumes the same amount of fields in each record is spitting out of your Cisco box, that there really are no line endings and that what you show above is really a single record.
I suspect there are some holes in my logic that need to be filled as I did not examine this closely, but then there are holes in the way this
problem was presented too.
I also suspect it might be worth while to look around
a bit to see if maybe someone has written something to do this kind of thing already.
Check sysadmin hangouts and network admin hangouts(find 'em via google) and look at CPAN. Stuff like this has been
done before in most cases, and you can save yourself a lot of time just doing a decent Google
search or two.
If, God forbid, you decide to try what I conceptualized above, make sure you look at Perlreref first! Hope this gives you an idea if nothing else.
...the majority is always wrong, and always the last to know about it...Insanity: Doing the same thing over and over again and expecting different results...