Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

by ww (Archbishop)
on May 16, 2009 at 12:01 UTC ( [id://764410]=note: print w/replies, xml ) Need Help??


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

  • Every third line
  • random selection
  • Some criterion susceptible to use of a regex
  • other?
  • 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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://764410]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (9)
As of 2024-04-16 08:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found