in reply to Efficient log parsing?

by using @x in @x = /($regex)/g you're telling perl to return a list from the regex. change it to a $x and the regex will return scalars

Replies are listed 'Best First'.
Re^2: Efficient log parsing?
by zrajm (Beadle) on Dec 14, 2007 at 07:09 UTC
    Ahh, but I'm also looking to obtain any subpatterns (paranthethized expressions) inside my regex. Putting @x there was ment to capture them.

    I naïvely thought m//g would return the same kind of stuff as m// without the /g flag, so that I could iterate over the string, obtaining one array of subpatterns at a time.

    But m// resets pos() and always begin at the start of the string, so that won't do either.

    Is there some way I could get m// to start searching where the last match left off? Using substr()? How efficient is that? Does it make a new copy of the string, or operate directly on the original?