Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
"Right now, when I click on a .pl, a dos terminal with strawberry perl exe on the top appears, executes the program and then disappears before I can lay eyes on it."

Yes, see, that's why I associated the .pl files with a bat file. Here's how to do it:

* On Windows XP, you would right-click on any .pl file, and go to "Open With..." and click on "Choose Program..." and then "Browse." Then find the bat file and put a checkmark next to "Always use the selected program to open this kind of file" and click on OK.

* On Windows 7, right-click on any .pl file, and go to "Open With..." and click on "Choose default program..." Then click on "Browse" and find the bat file and put a checkmark next to "Always use the selected program to open this kind of file" and click OK.

* On Windows 10, you have to right-click on any .pl file, and click on "Open With" and then "Choose another app" and then in the new window click "More Apps" and then scroll down and click on "Look for anther app on this PC." and then find that bat file, and put a checkmark next to "Always use this app to open .pl files." and click on OK.

The REG file changes the icon that appears next to .pl files. You can ignore that. That just changes the look and feel. If you do decide to use a custom icon for pl files, you have to get the icon file first, then edit the reg file. Make sure the paths are correct. Double-click on the reg file... and then associate the pl file with the bat file. That should be the last thing.

But you have to have the bat file ready first. I would just call it run.bat to make it short, and in your case it may look like this:

@ECHO OFF set TERM= set PERL_JSON_BACKEND= set PERL_YAML_BACKEND= set PERL5LIB= set PERL5OPT= set PERL_MM_OPT= set PERL_MB_OPT= C:\Strawberry\perl\bin\perl.exe -I C:\Strawberry\Perl\lib "%1" %2 %3 ECHO. PAUSE

Explanation: I am not sure why you have to set all those various environmental variables in the beginning, but I am assuming that they are necessary for something. So, we clear those values first. Then we call C:\Strawberry\perl\bin\perl.exe by giving its exact location. If you say you want to run the perl.exe which is located in the folder "C:\Strawberry\perl\bin" then you can be sure that that's the version of perl that will run! Especially if you also specify the location of the lib folder, you'll definitely get that perl running, and not something else. The %1 and %2 and %3 in the command line are the arguments. The first argument is the file name which is going to be %1. And then if you pass two more arguments to your perl program, then those would be %2 and %3. You could add %4 and %5 %6 %7 %8 %9 to make a full list.

So, let's say you're in command prompt, and you enter:

C:\Strawberry\perl>run.bat Hello World

In this case, your run.bat program runs the perl program and passes two arguments "Hello" and "World" so "Hello" becomes %2 and "World" becomes %3. Your perl program will receive those arguments. On the other hand, if you omit %2 %3 %4 etc... then your perl program won't receive any arguments even if you do try to pass some arguments.

The bat file is a pretty simple program. You could try and omit all those lines that start with "set" and see what happens. I think, those are totally unnecessary, but I could be wrong.

You could insert these two lines however:

SET PATH=C:\Strawberry\perl\site\bin;%PATH%
SET PATH=C:\Strawberry\perl\bin;%PATH%

These two lines add the strawberry bin folder to the path, so if perl or your program calls any executable that may be located in Strawberry/perl/bin, then those programs get executed.

Your path may already contain some references to other perl versions on your computer, so you could simply change the PATH instead of adding to it:


That's all you have to do, and it should work.

Okay. I am not sure what this is what you wrote:

"C:\Strawberry> Ftype Perl_program_file="C:\Strawberry\perl\bin\perl +.exe" %1 Ftype : The term 'Ftype' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + Ftype Perl_program_file="C:\Strawberry\perl\bin\perl.exe" %1"

If you're in the terminal window staring at command prompt, then you would run a perl script by entering the following command:


OR you could just enter:


This will work if you have added "C:\Strawberry\perl" to your system PATH. If you haven't yet, then go to Control Panel >> System >> Advanced >> Environment Variables. and find the Path string and update it by adding "C:\Strawberry\perl" to the end of the long string. Separate each path with a semi-colon ; So, your path string will probably look something like this :


In reply to Re^3: [implementation specific to windows] writing a proper batch file for terminal start-up by harangzsolt33
in thread [implementation specific to windows] writing a proper batch file for terminal start-up by Aldebaran

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (9)
    As of 2019-12-05 17:01 GMT
    Find Nodes?
      Voting Booth?
      Strict and warnings: which comes first?

      Results (151 votes). Check out past polls.