Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Pimp My RegEx

by Roy Johnson (Monsignor)
on May 31, 2005 at 18:47 UTC ( [id://462163]=note: print w/replies, xml ) Need Help??


in reply to Pimp My RegEx

I get better performance with this:
my $parse_log_entry = qr/^$dateRegex/ms; ... my $prevpos = 0; while( $logfile =~ m/$parse_log_entry/g ) { $count++; # count number of parsed strings if ($prevpos) { # print "Do something with $prevpos .. $-[0]\n"; # print substr($logfile, $prevpos, $-[0]-$prevpos), "\n"; } $prevpos = $-[0]; }
You would use the substr expression above to access what you're currently capturing, though you don't indicate that what you're capturing is actually used at all. .

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^2: Pimp My RegEx
by heathen (Acolyte) on May 31, 2005 at 20:30 UTC

    You would use the substr expression above to access what you're currently capturing, though you don't indicate that what you're capturing is actually used at all.

    I made a grossly simplified version of my script to share with the forum. Posting the script in its entirety would have just bored folks to tears! ...but rest assured, I am doing something with the captured text.
    I'm not sure your solution will work for log entries that span multiple lines.

      I'm not sure your solution will work for log entries that span multiple lines.
      Why not?

      Caution: Contents may have been coded under pressure.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-03-19 03:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found