5

I am new to xampp, and also, I am new to Perl programming. I just tried to open the file C:\xampp\cgi-bin\printenv.pl and I made a mistake.

I chose the default program to open that file extension as Notepad, with the option always use the selected program to open this kind of file.

Now when I try to run .pl files from cmd it opens them in Notepad instead of executing. Please reply. Thanks in advance.

aschultz
  • 1,658
  • 3
  • 20
  • 30
bunty
  • 51
  • 1
  • 4
  • Try using pl2bat or some modern variation of it (I haven't used windows for ages, so I don't really know). The point is turning a .pl into a .bat file which generally looks like `@C:\path\to\perl \nexit\n#!/usr/bin/perl -x`. -x means "ignore anything before the `#!perl` line. – Dallaylaen Jun 13 '12 at 06:36
  • [How do I make my Perl scripts act like normal programs on Windows?](http://stackoverflow.com/questions/4727480/how-do-i-make-my-perl-scripts-act-like-normal-programs-on-windows) – daxim Jun 13 '12 at 08:54

2 Answers2

9

Type the following at a shell prompt:

assoc .pl=PerlScript
ftype PerlScript="c:\...\bin\perl.exe" "%1" %*

(Replace ... with the correct path.)

ikegami
  • 367,544
  • 15
  • 269
  • 518
2

ikegami's suggestion did not work for me in Windows 10, but after finding Jack Wu's comment at ActivePerl. .pl files no longer execute but open in Notepad instead I was able to solve the problem as such:

  • Select and right-click a .pl file
  • Use the "Open With" submenu to "Choose another app"
  • Select "Always use this app to open .pl files" (do this now – you won't get the chance after you have selected a program)
  • Scroll to the bottom of the "Other options" to find "More apps", and select "Look for another app on this PC"
  • Navigate to C:/path/to/perl/bin/ and select Perl5.16.3.exe (or the equivalent, depending on which version of Perl you have installed: but not Perl.exe)

Then the Perl icon appears next to .pl files and a double-click leads to them opening in Perl every time, as desired.

Community
  • 1
  • 1
Martin Smith
  • 3,687
  • 1
  • 24
  • 51