How to execute Perl scripts in Notepad++

notepad++_perl_executeA few days ago I already described how to set up the Eclipse development environment for usage with Perl scripts. If you don’t want to use a sledgehammer to crack a nut,  you can also use the Notepad++ editor to relatively comfortably write Perl scripts.

Besides syntax highlighting and intellisense aka auto completion, Notepad++ also offers the possibility to execute Perl scripts directly from the editors interface. However, therefore a one-time setup is necessary, which I want you to briefly explain below.

Step 1 – create test scripts:

perl-skripte_in_npp_ausführen_1  perl-skripte_in_npp_ausführen_2

To be able to check if you have set up everything correctly later, you should definitely first create a small Perl script and save it. Important: Only stored scripts can be executed afterwards. So always save your script before clicking the “Run” button.

Step 2 – preparing the “Run” command:

perl-skripte_in_npp_ausführen_3  perl-skripte_in_npp_ausführen_4

In the Run dialog you must now specify the path to the Perl.exe on your computer. (The button with the three small dots opens a selection dialog.) Normally the Perl installation is placed directly on C:\ and the Perl.exe is located in a folder called “bin”.

Step 3 – set the “Run” parameter:

perl-skripte_in_npp_ausführen_5

Now you have to extend the command by the following parameter:

"$(FULL_CURRENT_PATH)"

Just look at the screenshot above, if you’re not sure how to set the parameter. Without these additional parameters indeed the Perl console would get opened, but our script won’t run.

Step 4 – create a hotkey:

perl-skripte_in_npp_ausführen_6

By clicking on the “Save” button you can create a shortcut aka hotkey to run your script.

Step 5 – test your result:

perl-skripte_in_npp_ausführen_7

Now everything should work. If you press your hotkey (combination) your script should be executed directly in the console now. As always, If you still have questions, write me a comment.

No products found.

13 Comments

  1. Wow it’s wonderful. Keep update with new blogs.

  2. I like this blog. Thank you for sharing this information.

  3. I know this comment is even freaking older now but I use:
    cmd /c C:\Strawberry\perl\bin\perl.exe “$(FULL_CURRENT_PATH)” && pause
    after the perl is executed, it leaves CMD window open with the message “‘Press any key to continue…” until (duh) a key is pressed

    • For some reason, when I cut and pasted, it changed my normal double-quote marks to start and end double quotes (“” vs “”). Needs the normal double-quotes!

      • Ah, it turns out quotes are automatically replaced when you post.
        You need unicode U+0022

        • OMG — this is endless!!!
          Sorry should be:
          cmd /k C:\Strawberry\perl\bin\perl.exe “$(FULL_CURRENT_PATH)” && pause

          where double quotes above are unicode U+0022 (Shift+2 on many querty keyboards).

  4. Ghanshyamsays:

    Did u try anything different ?

    I have tried reopening notepad++ , it shows the same behaviour :(.

    Thanks

  5. Ghanshyamsays:

    Thanks a lot for the info , i have followed the steps , its executing good , but the command console screen is seen only for a short duration , very tough to verify the output.

    Please provide the solution to it.

    Thanks again

  6. lukesays:

    It executes to the console but it immediately closes the console window, making it problematic to verify output

    • lukesays:

      nvm. I reopened notepad++ and it worked fine.

    • Sebsays:

      I know this comment is freaking old but I recently had this problem also… perl 2017 everyone.

      So I used this command instead:
      cmd /k perl $(FULL_CURRENT_PATH)

      Of course the perl command has to be included in the %PATH% var already but otherwise this looks like an easy command to me. Specially if you use something like Strawberry to change between different perl versions, this is a flexible way to go.

Leave a comment

Please be polite. We appreciate that. Your email address will not be published and required fields are marked