in reply to Re: Getting lines in a file between two patterns
in thread Getting lines in a file between two patterns

So, I've implemented your code, which is getting me closer to the goal. Thank you for that.

Here is what I've got running:

while (<INPUT>){ if ($_ =~ /HISTORY/../TABLE/){ open(OUTPUT, '>'.$outputfile) or die "Can't create $output +file.\n"; print OUTPUT "$_\n"; close OUTPUT; } }

The data I'm trying to pull out is in a table (in Word) and it will find the flip/flop, print it to the OUTPUT. That much is working. However, the data it returns is a jumbled mess of characters. It isn't intelligible.

So, I tried saving a docx as rtf... no luck (it won't copy the table data, only gobbledegook), then I tried .txt... That returns the text/data, but I lose the neat and tidy layout of the table.

Any suggestions on how to copy the table as a table or at least delimited somehow?

Thank you again,
Daikini

Replies are listed 'Best First'.
Re^3: Getting lines in a file between two patterns
by 1nickt (Canon) on Oct 31, 2015 at 03:53 UTC

    You have your file-opening code inside the loop through each line. It should be moved outside, so the file is only opened once instead of once for every line (and overwritten each time), and also would be better written as:

    open my $OUTPUT, '>', $outputfile or die "File open fail: $!\n";
    See open.

    As far as your data foramtting question, you probably should use a module for reading your Windows file format, maybe Win32::OLE? (disclaimer: I haven't programmed with Windows for years; search CPAN and you'll almost certainly find what you need if that's not it.)

    Hope this helps!

    The way forward always starts with a minimal test.