in reply to Re^2: Avoid memory error while extracting text block
in thread Avoid memory error while extracting text block
If the intent is to split this compound file into separate files, I think I'd do soemthing like this:
#! perl -slw use strict; # assuming the name of the compound file is supplied on the command li +ne until( eof( ARGV ) ) { my @buffer = <>; ## Put the <DOC +UMENT> tag into a clean buffer push @buffer, scalar( <> ), scalar( <> ); ## Ditto <TYPE> + & <SEQUENCE> my( $filename ) = ( my $line = <> ) =~ m[<FILENAME>(\S+)]; push @buffer, $line; open OUT, '>', $filename or die $!; print OUT for @buffer; print OUT until ( $_ = <> ) =~ m[</DOCUMENT>]; close OUT; }
Note:That is untested code and will probably need tweaks. Eg. I'm not convinced that it will print the final tag to the output files; but then maybe you'd want to strip those anyway.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Avoid memory error while extracting text block
by wrkrbeee (Scribe) on Apr 14, 2016 at 12:59 UTC |