20090625 running perl scripts in notepad - plembo/onemoretech GitHub Wiki

title: Running perl scripts in Notepad++ link: https://onemoretech.wordpress.com/2009/06/25/running-perl-scripts-in-notepad/ author: lembobro description: post_id: 299 created: 2009/06/25 15:27:19 created_gmt: 2009/06/25 15:27:19 comment_status: closed post_name: running-perl-scripts-in-notepad status: publish post_type: post

Running perl scripts in Notepad++

I recently began using Notepad++ on my Windows systems instead of tried-and-true Textpad, mostly because my license for the latter doesn’t cover the latest version and I’m tired of going through the whole registry editing thing to make an old copy it work on new systems.

Notepad++ is a very powerful and versatile text editor for Windows whose peers include Textpad and Ultraedit. While both the later are shareware, Notepad++ is, at least for now, completely free (although contributions are welcome!). While I do most of my development work in Eclipse cross-platform or in gedit when on Linux, I’m finding Notepad++ to be a perfect addition to my toolkit on Windows.

One nice feature of most modern editors is the ability to run scripts from within the editor. On Linux gedit has offered this since at least v2.16.0, the version that ships with Red Hat Enterprise Linux. Making it work with Notepad++ is pretty straightforward. Here’s the step-by-step:

NOTE: NPPExec may not be installed when you first set up Notepad++. If it isn’t, run the Plugin Manager (Plugins… Plugin Manager) to install it.

1. Click Plugins… NPPExec… Execute.

2. Type the following into the window:
c:/perl/bin/perl "$(FILE_NAME)"

3. Save the script (I just called it “Perl”).

4. Now click Plugins… NPPExec… Advanced.

5. In the Menu Item section to the lower left, type what you want to appear on the Plugins menu (I chose “Perl Interpreter”, then click on the Associated Script drop down and select the script definition you saved in step 3 above. Click Add/Modify.

6. Go back to Plugins… NPPExec and you should see your menu item listed near the bottom.

7. Make sure that the following option is checked on the Plugins… NPPExec menu:

Follow $(CURRENT_DIRECTORY)

This will cause the file being executed to do so with the CURRENT_DIRECTORY context set as “.” or “root”, allowing scripts that use relative file paths (e.g. my $file = "../thatfile.txt") to find what they’re looking for.

Copyright 2004-2019 Phil Lembo