in reply to Shorten script

Here's my go.

while( <F>){ for $hit ( /matchPattern/gi) { print "PAGE ->\t$name\ndata ->", /(patternOne)/gi or /(patternTwo)/gi ? "\t\t$1\nMATCHED - >\t$hit\n" : "TEXT INFO HERE.\n"; push (@files, $name); $ct++ } } close F;

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller

Replies are listed 'Best First'.
Re: Re: Shorten script
by ihb (Deacon) on Jul 23, 2003 at 08:42 UTC

      ++ Well picked up on the or thing. I really should have added an "untested" rider to that code. It was purely an editor exercise and completely untested. I should have spotted the error, but I tend to use or rather than || as a matter of course and let the compiler inform me when I need to change it. Hey, that's what compilers are good at :)

      With respect to the non-localisation of $_ in while loops. Your right to point it out. It's one of those things that I take on a case by case basis, but it is so useful, that I wouldn't want to never use it.

      Does anyone know if there is a good reason why $_ isn't localised in while loops as it is in for loops?


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller

Re: Re: Shorten script
by Anonymous Monk on Jul 22, 2003 at 19:26 UTC
    Thanks for ALL your replies!!! I now see it looking better.