http://www.perlmonks.org?node_id=1186449


in reply to oneliner: autorun script when I save it in the editor

Nice one! I modified it a bit to compile and run a C program:

perl -E 'while(-f $ARGV[1]){ $now=(stat(_))[9]; system("@ARGV"), print + "-" x 80, "\n" if ($now-$prev); $prev=$now; sleep 1 }' gcc a.c \&\& +./a.out
I think every Unix/Linux sysadmin should know shell (sh or bash) plus one of Perl, Ruby, Python. It doesn't matter which. -- Tom Limoncelli (http://everythingsysadmin.com/2012/06/salang.html)

Replies are listed 'Best First'.
Re^2: oneliner: autorun script when I save it in the editor
by FreeBeerReekingMonk (Deacon) on Apr 02, 2017 at 17:43 UTC
    The delimiter line is a nice touch...

    And using $ARGV[1] instead of $ARGV[0] is good thinking! I now use it more as a perl -wc thingy... so I save, and know if the added code is syntax-error free (of course, most of the times it is still buggy)