rajkrishna89 has asked for the wisdom of the Perl Monks concerning the following question:

Im trying to extract some data from .doc files..im able to open and read but i got an issue in extracting...when my search pattern is matched i need to print the contents which is present in the next cell in the document(TAB)...

DATA:- Username: Password:

Username is in one cell and Password is in another cell...once username is matched i have to press tab to go to next cell...similarly how can i get the data from the next cell using perl...

Search Pattern:- for ($i = 0; $i <@array; $i++) { if($array[$i] =~ /Username\s*:\s*(.+)/) { $result = $1;

$arrayi contains the data of the document file...Thanks monks...

Replies are listed 'Best First'.
Re: Extracting data from table
by roboticus (Chancellor) on Sep 14, 2012 at 13:42 UTC

    rajkrishna89:

    If by .doc file you mean a Microsoft Word document, the data is stored in a very complex manner. (Look at the data file using a binary editor and take a look!) If so, you'll have better luck using the Win32::OLE module if you're on a Windows box.

    If you're on a unix box and the file is in the XML version of a doc file (.docx), then an XML parser and some slogging through the Microsoft Word object model documentation would be the way to go.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Re: Extracting data from table
by Anonymous Monk on Sep 15, 2012 at 00:05 UTC

    Hi,

    Once you have a match on $array[$i], $array[$i+1] should contain your answer. Hopefully.

    J.C.