in reply to Call for code samples!

I only remember this vaguely, but a while back I had a co worker ask me to write a simple parser to parse a proxy-cache log entry, sort of similar to Apache logs... where entries could be:

He encountered problems because he was trying to separate out the fields using split. Obviously, since an entry can contain spaces if it's quoted, you couldn't really split()

So the approach I took was something like this:

# untested... I'm sure this doesn't really work... while( $line =~ m{\G\s*(\[\w0-9]+|"(?:[\w0-9]|"")+")}g ) { do_something_with_match($1); }

something like that. come to think of it, it's probably not a good example... oh well. my $0.02