Dearest Monks,

I don't understand why the following piece of code does not work the way I expect it (it opens a command prompt window when I expect it to open notepad). My goal is to open a .txt file in its native application which I assume to be notepad. The file is created and closed before I attempt to run this piece of code.
sub logfile{ my $file = "$gGui{complogpath}/$gGui{complog}.txt"; my @args = ("start",$file); for (@args) { if (/ /) { $_ = qq{"$_"}; } }; system(@args) == 0 or warn "Couldn't launch '$file' : $!/$?/$^E"; }#logfile
The following code opens Guide in its native application (adobe). In this case I don't worry about the path because I know that that file is in the same folder than the application code.
sub help{ my $file = "Guide.pdf"; my @args = ("start",$file); for (@args) { if (/ /) { $_ = qq{"$_"}; } }; system(@args) == 0 or warn "Couldn't launch '$file' : $!/$?/$^E"; }#help

In the first code that does not work, I have to give the full path and I have a feeling that it is the problem. I don't pass all the pieces correctly. (?)

I would appreciate any thoughts you may have.

Thanks in advance for your time.

Claire

In reply to Opening a text file in its native application by FM

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.