in reply to Opening file and checking for data

If you are using a string in your regular expression that will not change on each iteration of your loop, consider adding the /o operator like so:
if($_ =~ /patternmatchinghere/gio)
This will compile the regular expression only once, as opposed to once for every loop iteration. On a large amount of data, this will speed up your code significantly.

Replies are listed 'Best First'.
Re: Re: Opening file and checking for data
by hardburn (Abbot) on Jul 03, 2003 at 14:19 UTC

    /o is dead, long live qr//!

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    Note: All code is untested, unless otherwise stated

      Good point. I honestly forget about qr// most of the time, but this was a good reminder.