Sometimes you get spoiled by IDE's that have F5 to save and run what you have scripted so far... so... what can you do if you have 2 xterms (one for vi, the other for the output)?

perl -E 'while(-f $ARGV[0]){ $now=(stat(_))[9]; system($^X,@ARGV) if($ +now-$prev); $prev=$now; sleep 1}' /home/user/ foo bar

with having:

#! env perl my $p1 = $ARGV[0]; my $p2 = $ARGV[1]; print "param1=$p1 param2=$p2\n";


param1=foo param2=bar

Tested to work under Win10 and Linux

Of course, there are better implementations. inotifywait or auditd if available on your system...

any perl golfers?

Update: we now incorporate the improvement made by haukex. Feel free to add more parameters if you need these