in reply to Parsing Large XML

Using Tie::File takes up *more* memory than not.

Your memory problems would be avoided by printing the results as you find them instead of saving them in an array and printing them all at once.

There are other issues.

Replies are listed 'Best First'.
Re^2: Parsing Large XML
by shravnk (Initiate) on Jul 06, 2010 at 13:41 UTC

    ikegami-

    Sorry, I'm new to Perl, and programming in general, and was somewhat confused by your comments. A couple of questions:

    - What is an acceptable alternative to $[ ?

    - Could you suggest a way to print each result as it is found?

    I greatly appreciate your help.

      What is an acceptable alternative to $[ ?

      Not using it. It adds needless complexity.

      If you insist,

      $[ = 1; $a[$i]
      can be written as
      use constant BASE => 1; $a[$i-BASE]

      At least there's no hidden effect at a distance this way.

      Could you suggest a way to print each result as it is found?

      To print the results instead of saving them in an array, replace the code that places them in the array with the code that print a match.

      for (@stories) { print $fh $_ if /$fields[1]/; }
      A reply falls below the community's threshold of quality. You may see it by logging in.