perl.exe vs. cmd.exe

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Perl Beginner
    New Member
    • Sep 2007
    • 57

    perl.exe vs. cmd.exe

    A few days ago, i was trying to make my perl script an executable (with no success). but that's not the direction of my question (at least not right now).

    Once i stopped trying to make the executable work, i ran my perl script as a perl script (*.pl), but now when the console window comes up when it runs, i noticed that it's running through C:\Windows\syst em32\cmd.exe instead of C:\Perl\bin\per l.exe...which is causing the script to freak out and not run properly! The first line in my code is
    Code:
    #!/usr/bin/perl
    which looks for the perl interpreter.

    WHAT DID I DO?!?! And how can i get it back to normal and execute using perl.exe??

    By the way (if this helps), i tried making the perl script an executable by using PAR and also Perl2Exe.
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    Windows does not use the shebang line. You can tell because it is ignoring your incorrect shebang line which is for a typical Linux computer. On winodws you can open a DOS window and type:

    c:\>perl path\to\program .pl

    or if perl is not in the command path:

    c:\>perl\bin\pe rl.exe path\to\program .pl

    that will run your perl script. If you want to click on your perl program and have it run you have to associate .pl with the perl executable. But that opens a dos/perl window, runs the program, and closes the dos/perl window, which may not be what you want to do. There is probably a way to make the window stay open, but I don't know how off the top of my head.

    Comment

    • Perl Beginner
      New Member
      • Sep 2007
      • 57

      #3
      Originally posted by KevinADC
      If you want to click on your perl program and have it run you have to associate .pl with the perl executable.
      Thanks Kevin, this is where the root of my question is...how do i associate the .pl with the perl executable when i just doubleclick to run it?

      i know how to make the dos window go away while the script is running. i will use the following two lines:

      Code:
      my $hw = Win32::GUI::GetPerlWindow();
      Win32::GUI::Hide($hw);

      Comment

      • KevinADC
        Recognized Expert Specialist
        • Jan 2007
        • 4092

        #4
        Originally posted by Perl Beginner
        Thanks Kevin, this is where the root of my question is...how do i associate the .pl with the perl executable when i just doubleclick to run it?

        i know how to make the dos window go away while the script is running. i will use the following two lines:

        Code:
        my $hw = Win32::GUI::GetPerlWindow();
        Win32::GUI::Hide($hw);
        Since file association can be very different depending on what version of windows you are running, I suggest you ask on a Windows forum how to associate a file type with an executable. Or just try reading the Windows help files.

        Comment

        Working...