in reply to searching for multiple lines from outfile and printing them all in the final outfile

OP and OP's additional notes suggest that the objective is a multi-level or "tiered" selection of data.

  1. Select from among many inputs to one "output file"
  2. Then sub-select lines from "output file" to a "final output file."

The problem then, is the OP's non-specification of the criteria by which one discards some lines from the "output file" and/or selects others for inclusion in the "final output file."

If this is indeed what you intend, Annonymonk, please let us know. Is the basis for subselection to be

  • Comment on Re: searching for multiple lines from outfile and printing them all in the final outfile

Replies are listed 'Best First'.
Re^2: searching for multiple lines from outfile and printing them all in the final outfile
by Anonymous Monk on May 18, 2009 at 19:29 UTC
    it is sub-select lines from "output file" to a "final output file." and random selction from output file.

    am I clear or please let me know if you need mroe information.

    Thanks a lot.

      Assumes @output is populated from your source; prints to console:

      for (0..9) { print $output[rand($#output)] . "\n"; }
      • Printing to your final_output.txt file is left as an exercise for the student (since you've already solved that).
      • This is likely to select duplicate_lines to your final file, which is still permitted by your spec (but which -- I think -- is not actually your intent). Search the Monastery for unique or @seen and similar for the many solutions to avoiding duplication.
      • There is not need to create an output file (thereby eating cycles and disk space); do your initial selection from the source to an array @output.