|
|
| Do you know where your variables are? | |
| PerlMonks |
(jeffa) Re: split delimiters IIby jeffa (Bishop) |
| on Mar 26, 2001 at 21:57 UTC ( [id://67370]=note: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.
Unless you post a complete example of the line to be parsed,
we cannot help you. Since I am a nice guy, though, I will
explain why you need more than split for this problem.
The better solution would be to use the m// operator and the grouping variables: $1, $2, etc. I'll explain by parsing an entry from an Apache web server access log Each entry is seperated by dashes, brackets, or quotes - but since we know the general layout, we can write a regualar expression that is general enough to parse each line, but specific enough to get the data we want - just the IP of the referrer, the date stamp and the requested document ( along with request type) By no means I am an master of regular expressions, the ones I chose just happen to work - there are better ways then using .* - but a little badness won't kill ya' :) Big Thanks to Albannach. Jeff
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||