in reply to Re: Am I doing Greedy Matching?
in thread Am I doing Greedy Matching?

In the first step, i read in a line and chop it up on the "space" delimeter into @parts.

You also chomp the line which isn't required because (.*) will not match a newline.

And you are using the /o option which is superfluous because there are no variables in the pattern to interpolate.

Replies are listed 'Best First'.
Re^3: Am I doing Greedy Matching?
by cavac (Prior) on Nov 10, 2011 at 21:56 UTC

    You also chomp the line which isn't required

    Quite right, it isn't required (and could hurt performance slightly on a big file). Over time, it has become part of my coding style to always use chomp when reading from a filehandle. More than once did i change the regex or some other part of the code and suddenly wondered where the newline came from. So i started using chomp unless required otherwise.

    And you are using the /o option which is superfluous because there are no variables in the pattern to interpolate.

    Again you are quite right. Does this actually hurt performance? I find it rather helpful when coding, even in static expressions, since i could just glance at the end and see "ok, this isn't a dynamic regex" instead of looking through the whole line noise for variables.

    But thats probably just me. You know, old dogs, new tricks...

    Don't use '#ff0000':
    use Acme::AutoColor; my $redcolor = RED();
    All colors subject to change without notice.