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

I want to open up the Outlook.exe for my Outlook mail on my NT workstation.
Is this possible where I open up the Outlook.exe and it will open up the Outlook mail on my workstation?
When I run this it pulls up alot of "junk" basically pulling up executable syntax, in other words I need assistance with this.
$outlookmail="/Program Files/Microsoft Office/Office/Outlook.exe"; open(FIL,$outlookmail); @lines = <FIL>; close FIL; foreach (@lines) { print; }

Replies are listed 'Best First'.
Re: Opening up executable file
by Fletch (Bishop) on Jan 08, 2003 at 17:39 UTC
    • You want system, not open (see perldoc -f system).
    • You also probably need a perl tutorial or book.
    • You should always check the return value from open() (not that that's germane here, but . . . ).
Re: Opening up executable file
by Paladin (Vicar) on Jan 08, 2003 at 17:42 UTC
Re: Opening up executable file
by gmpassos (Priest) on Jan 08, 2003 at 18:23 UTC
    What you want is to execute Outlook, not?

    Well, you have a lot of ways to do that on Perl, but I preferrer a portable way, that works on UNIX too:

    my $outlookmail = "c:/Program Files/Microsoft Office/Office/Outlook.ex +e" ; open (CMDLOG,"| $outlookmail") ;

    Your path for Outlook has some spaces, probably you need to declare de variable in this way:

    my $outlookmail = '"c:/Program Files/Microsoft Office/Office/Outlook.e +xe"' ;

    Graciliano M. P.
    "The creativity is the expression of the liberty".

      thanks that works. I need to make it a link or button on a web page so I can put it on a web page and then run this it will open up my mail. Would I just need to create a link in my cgi page or how would I do this? Please advise.
        blah use <a href="mailto:">Open Mailer</a>

        -Waswas
[OT] File Slurping.
by vek (Prior) on Jan 08, 2003 at 18:01 UTC
    I think fletch has nailed this one so I just thought I'd make a general OT observation here about reading files with Perl for your future reference.

    Be careful when using code like this: @lines = <FILE>;. What you're doing here is known as slurping. In other words you are reading the entire file into the @lines array and thus memory. This may not be a problem with small files but might present a problem when dealing with large files. Consider using the following code for reading files:
    my $file = "/path-to/somefile"; open(FIL, $file) || die "Couldn't open $file - $!\n"; while (<FIL>) { #do stuff with each line of $file } close(FIL);
    -- vek --