Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Call for code samples!

by lestrrat (Deacon)
on Nov 15, 2001 at 14:41 UTC ( [id://125544]=note: print w/replies, xml ) Need Help??


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:

  • all alpha-numeric characters w/o any whitespace
  • double-quoted alpha-numeric characters ( whitespaces allowed ) where a double-quote is escaped with another double-quote

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://125544]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-19 19:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found