Today I am going to explain how you can be using
Notepad++ to run Perl scripts.
It can be convenient to launch your program directly from the editor's environment to quickly check that it compiles.
Let's try and set up Notepad++ to launch the script from
Wednesday's post.
In the Plugins menu, you will find the NppExec plugin.
Select Plugins>NppExec>Execute...
You can also use the convenient F6 shortcut.

Once the Execute... window is open, type in the following command:
perl "$(FULL_CURRENT_PATH)"$(FULL_CURRENT_PATH) is an internal Notepad++ variable that contains the full path of the file currently open in the editor.
There is a list of 10 such global variables
here. We might come back to them later.
So, hitting F6 for our example is equivalent to typing the following line in a DOS shell:
perl C:\Perl\usr\skeleton2.pl
You can save this command line and give it a meaningful name ('perl' for example).
Of course, you can enter any command (or sequence of commands) that you would type at a DOS prompt:
perl -v
dir
...
The output result is visible on the Console window.

You can get rid of the "Process..." lines by selecting
Plugins>NppExec>No Internal Message
Also, if you want to repeat the previous command, you can just type Ctrl+F6.
If you know more Notepad++ tips, I'd love to hear from you!
A few words about the new skeleton:
The
-w added at the end of the
shebang line is the equivalent of
use warnings;
$PROG_NAME,
$VERSION and
$PROG_DATE are called scalars. They are composed of a
$ followed by a variable name. Scalars are used to represent a single element (in this case, they are all strings, because initialised as characters between double quotes).
The
my function has to do with the scope of the variables. It is optional but I was told it is good practice to use in conjonction with the
use strict command.
We'll see if we can figure out why later. If you have a clue, please drop a comment.
Finally, the last line makes use of the variables declared at the top of the script:
- print "This is $PROG_NAME $VERSION from $PROG_DATE.\n";
print "This is $PROG_NAME $VERSION from $PROG_DATE.\n";
Strings between double quotes (") are interpolated. This means that when the Perl interpreter sees
$PROG_NAME between quotes, it will replace it by its current value.
If you replace the " by a single quote ('), then the output will become:
This is $PROG_NAME $VERSION from $PROG_DATE.\n
Come on, try it! All it takes are 2 key strokes and Ctrl+F6!
Finally, "\n" is understood as the next line character.
Today's French expression would not get approval from Larry Wall:
"La paresse est source de tous les vices": An idle person is the devil's cushion.
"Paresse" is the French word for lazyness. This is a quality for a developper according to Larry, because it pushes him/her to create scripts in order to automate his work and avoid repetitive tasks.
New posts:
- Our first Perl program - Part II: parsing the Perl command line
- More about CPAN
- Our first Perl program - Part III: Add a GUI interface
- How to install Google Analytics on your Blogger blog
- First version of FileInfo script
- Perl help resources