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

Thanks guys, all I needed was 'name of file.xls;' and it opened it up on the screen for me. The system command would have worked too, Jonadab, thanks. Hello,

I need to get my perlscript to open a file and display it. That is, open it so the user can see the file and then work in it. Is this possible, and how do I do it, please?

Eyidearie

Replies are listed 'Best First'.
Re: Open a file the way Ctrl+O works
by jonadab (Parson) on Aug 10, 2005 at 19:22 UTC

    You know about the system command, right? I would recommend the multi-argument version, e.g., something along these lines...

    system($path_to_excel, $path_to_file);

    There is also Spreadsheet::ParseExcel. The benefits of going that way are twofold: the script can then do stuff with the file, and you don't have to have Excel installed in order to do it. However, I think the system command is closer to what you were asking for. This means you need Excel (or some equivalent program that can open its files, e.g., OpenOffice.org) installed on every computer where you plan to run the thing, and it also means the script can't do anything useful with the file; it just opens for the user to work with, that's all. But I think that's what you were asking for.

Re: Open a file the way Ctrl+O works
by gellyfish (Monsignor) on Aug 10, 2005 at 18:02 UTC

    I think you are going to have to explain what "see the file and then work in it" means, after all this could be as simple as:

    my $editor = $ENV{EDITOR} || '/usr/bin/vi'; system($editor, shift);

    /J\

      I need to open an excel file which contains a button to execute the second part of the project. I am working on a Windows OS. Thanks.

        I guess you are going to want to use Win32::OLE - you can find hundreds of articles here on the subject.

        /J\

Re: Open a file the way Ctrl+O works
by Fletch (Bishop) on Aug 10, 2005 at 18:18 UTC
      I guess I should have said,

      When I run the program I want it to open and display an excel file. This means I don't want to open and read or open and append etc, just open the excel file as though I had manually gone into excel and clicked file -> open.

      I hope this helps. Thanks.

Re: Open a file the way Ctrl+O works
by Anonymous Monk on Aug 10, 2005 at 18:00 UTC
    What kind of perlscript is it, commandline?
      Err... I think so.