Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
splitting a string that appears inconsistently in structureby TheGorf (Novice) |
on Jan 02, 2009 at 00:45 UTC ( [id://733688]=perlquestion: print w/replies, xml ) | Need Help?? |
TheGorf has asked for the wisdom of the Perl Monks concerning the following question:
Ok thanks to everyones recommendation here for Apache::LogParse I have managed to build a quite effective log parsing tool. Except... The logfiles all have the request part of the logfile in quotes as one string. So it looks like this normally: GET /some/path.php?somevalue=eddie HTTP/1.1 but the problem is that it doesn't ALWAYS look like that. But somehow I need to slit that string into the Method, Request (before the ?), URI query (after the ?), and the protocol version. If I just split it based on the string above I of course run into the problem of "Use of uninitialized value in concatenation (.) or string" because of course the variables I split into get set as undefined due to the string not always appearing consistently. Sometimes it's lacking the protocol version, sometimes there isn't a URI query, sometimes the whole string is just one clump of characters due to some goofy attempt against the web server. So I'm hoping someone can offer advice on how I can do this so that if the string doesn't contain all four components, the variable just gets set to "" or something. so far I am stuck just doing something like this:
help?
Back to
Seekers of Perl Wisdom
|
|