When you say "I get nothing", I think you really meant to say that you get an error message and to actually tell us exactly what that error message was (cut'n'paste it).

I'd guess that your PATH got updated but you were trying to run the Perl script in a command window that didn't have the up-to-date PATH. See CleanPath for once way to make dealing with this a bit easier.

The trailing \ that you noticed wouldn't have been a problem (as you verified). You most likely used the GUI to change the environment settings and this notifies your desktop 'shell' (explorer.exe, not the command 'shell' that Unix users are used to thinking of when they hear 'shell') to fetch the latest environment settings. If you then open a new command prompt, it will have the updated PATH (so that perl.exe can be found).

And, of course, the claims in this thread that you can't pass arguments via file associations in Windows are wrong (as you verified).

See what you get when you run these commands:

C:\>assoc .pl .pl=Perl C:\>ftype Perl Perl=perl -Mouse "%1" %* C:\>

My output shows that I've set my associations to use my -Mouse module so that double-clicking a *.pl file (or drag'n'dropping to a *.pl file or downloading a *.pl file from a trusted web site [risky!]) will not create a command window that just disappears when the script finishes or fails.

The %* is what causes the arguments to get passed along. The "%1" is the name of the script and the quotes are what allow it to work on paths/files that contain spaces.

You might also like to try pl2bat. Although the bug of "script.pl >output.txt" and "script.pl | more" not working with file associations has been fixed in modern versions of Windows, I still use pl2bat for all of my Perl scripts (in part so that my -Mouse trick doesn't affect scripts meant to be run from the command line).

- tye        


In reply to Re: perl script on Win32 (stale env) by tye
in thread perl script on Win32 by jellyroll10

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.