|
|
| Problems? Is your data what you think it is? | |
| PerlMonks |
Re: help with splitting and printing the arrayby blindluke (Hermit) |
| on Jan 24, 2015 at 20:54 UTC ( [id://1114388]=note: print w/replies, xml ) | Need Help?? |
|
Hello, perlnewbie012215, welcome to the Monastery. First of all, start using use strict; use warnings; This would help you with the mistake of storing localtime in $datestring and trying to print $date. Your biggest problem is the fact that you are splitting the log line into words (roughly), and you are counting that the server1.prod.com will be the sixth word. You already know what happens if some additional parameters show up before the server name - the count is off. But what happens when someone switches the order of parameters? Try using a regular expression to match the specific parameters, and not counting which word is the server name. UPDATE:
Take a look at this small script operating on your sample data. This should hopefully set you on the right track.
The output:
- Luke
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||||||||