in reply to Re: Pattern Matching Question
in thread Pattern Matching Question

Note that Tie::File does not read the whole file to memory.

Replies are listed 'Best First'.
Re^3: Pattern Matching Question
by NetWallah (Canon) on Nov 30, 2004 at 07:03 UTC
    Noted.

    But why encumber the module overhead when all you are doing is a sequential read ?

        ...each is assigned his own private delusion but he cannot see the baggage on his own back.

      TMTOWTDI! The original poster mentioned reading the file to an array, so presumably that way of thinking comes more naturally for him. I'm not suggesting my version was "best"; but Tie::File *is* better than the @lines = <FILE> the OP wanted to do while allowing the same (or close enough) semantics later.

      Your method is perfectly valid, of course, and I write code like that all the time. (Though nowadays I am more likely to use a lexical filehandle.) I also alternate between using Exporter and writing my own import routines that do the same thing. It depends on what I'm optimizing for, and sometimes *that* is just writing the code quickly, so whatever comes to mind first gets to be used.