I have what is probably an easy question but I/O stuff always confuses me. Basically, I am parsing a document with many repeated records. However, I have to clean the document before I can parse out the data. As is, my program cleans the original input, outputs it into a file, and then inputs that file to begin the parse. I really don't mind this work around (and it works fine as is) but the file that I am going to have to parse will be huge (like several gigs and I don't know if creating an intermediate fill will be a problem memory-wise). Is there a way to take out the intermediate step such that the output from the "cleaning" can be accessed without printing to another file?
The beginning of the program involving the creation of the first output and then accessing it (creating a second output) is as follows:
...etc, etc...the rest of the program is just the data that I pull from the records. Any advice would be much appreciated. Best, Michaelopen(OUT, ">/Users/micwood/Desktop/output.txt"); while (<>) { s/\r//g; s/\t//g; s/(<h4>Award\s\#\d+<\/h4>)/\nEND-OF-DOCUMENT\n$1/g; s/(<!-- \/noindex --><\/font>)/\nEND-OF-DOCUMENT\n$1/g; print OUT "$_";} close OUT; open (IN, "/Users/micwood/Desktop/output.txt"); open(OUT2, ">/Users/micwood/Desktop/output2.txt"); my $allDocs = do { local $/; <IN>; }; my $rxExtractDoc = qr {(?xms) (<h4>Award\s\#(\d+)<\/h4>(.*?)END-OF-DOCUMENT) }; while ($allDocs =~ m{$rxExtractDoc}g )
In reply to Using output again without printing by micwood
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |