perl-c-ontinuos

TL;DR

A little shell script to keep a Perl program under check.

When I’m working on a Perl program, every now and then I do some basic check to see if it compiles and its syntax is OK:

$ perl -c some-program.pl
some-program.pl syntax OK

That’s because… well, sometimes a syntax error actually gets in:

$ perl -c some-other-program.pl
Global symbol "$whatever" requires explicit package name...
...
BEGIN not safe after errors--compilation aborted ...

It can be useful to keep a program under continuous check, in the sense that I want to figure out quickly when it breaks the compilation. The following script does exactly this in a Linux machine with inotifywait (part of inotify) installed:

Local version here.

Use it by passing the name of the Perl program you want to monitor:

$ perl-c-ontinuous whatever.pl 

/path/to/whatever.pl syntax OK
-------------------

syntax error at /path/to/whatever.pl line 8, near "my "
Global symbol "$original" requires explicit package name ...
...
BEGIN not safe after errors--compilation aborted ...
-------------------

/path/to/whatever.pl syntax OK
-------------------

At each save, the perl -c command is executed, and in case of syntax errors… an error message is printed. Thanks to inotify this can happen only upon saving the file, sparing system resources.


Comments? Octodon, , GitHub, Reddit, or drop me a line!