http://www.perlmonks.org?node_id=999078


in reply to Parsing multiple excel files in perl

Seeing the codes you posted I guess your problem is really with design rather then with Perl itself. Codes posted are not complete, so I assume you face following:

You have GUI application, in which after pressing some button 'Open file' dialog is displayed, where you choose file to be opened, then subroutine (which you pasted) is run in order to do stuff with this file. Am I correct that your problem is that you don't know how to allow user choosing more than one file from dialog box? And another thing is how to pass result of this dialog box to subroutine in order to open more files?

This kind of information is what we need. If you answer yes to those questions, then you should consider following two approaches (I don't know API of GUI you use and don't know if it allows such operations): 'open file' dialog window should allow user to choose more than one file (standard way on Windows is with Ctrl key) or you should open 'open file' dialog window in the loop as many times as there are files to be processed.

So if you were able to present following code of your GUI:

$window->create("my main window"); $window->addbutton(somex, somey, somewidth, someheight, name, \&mysub) +; sub mysub { my $result = $window->openFileDialog(...); # error check open FH "$result" or die $!; # parsing file close FH; }
you could get proper help from us. Of course in case my assumptions are correct.

Replies are listed 'Best First'.
Re^2: Parsing multiple excel files in perl
by reaper9187 (Scribe) on Oct 15, 2012 at 17:12 UTC
    Hi.. Thank you for replying
    Well you pretty much right about the GUI part.
    However, my problem is slightly different from the one u mentioned here.
    I'm actually trying to choose multiple files using multiple dialog boxes( jus a part of the user interface) and then pass these filenames as arguments to the parser which then sequentially checks the cell values and compares it to a set threshold and gives out the results. I'm not able to parse multiple files simultaneously after passing the filenames as arguments
    Thanks again
      Then you have problem with algorithm parsing files? Because opening multiple files is simple, you just use different file handles:
      open FH, "file1" or die $!; open FH2, "file2" or die $!; $readlinefromfile1 = <FH>; $readlinefromfile2 = <FH2>; $readfromfile1again = <FH; close FH2; close FH;
        Thanks again .. I figured it out .. It's working fine now.. Thank you everyone for taking the time out to chip in .