in reply to onchange - a script to run a command when a file changes

This code appears to run the same command on the same file for each updated file in @ARGV[1..$#ARGV]. The list form of system in a perl-style loop over file basenames would work better.

I'd be inclined to do this with make, either called from perl or in a frequent cron job.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: onchange - a script to run a command when a file changes
by sauoq (Abbot) on Nov 21, 2003 at 02:01 UTC
    This code appears to run the same command on the same file for each updated file in @ARGV[1..$#ARGV].

    Well, it doesn't run a command "on the same file" exactly. It just runs a command. I agree it would be more useful if it could somehow supply the filename of the changed file to the command. I can't seem to find it right now, but I had something that did just that. I used File::Signature to watch the file (which was probably overkill.)

    I'd be inclined to do this with make, either called from perl or in a frequent cron job.

    By default, he is checking for changes every half a second. Cron wouldn't make a good substitute for that.

    -sauoq
    "My two cents aren't worth a dime.";
    
Re: Re: onchange - a script to run a command when a file changes
by samtregar (Abbot) on Nov 21, 2003 at 23:21 UTC
    I considered adding an option to supply the file that changed, but I decided it wasn't that useful to me. Obviously it would be an easy change.

    As far as using cron, it takes too much work to setup and take down a cronjob. I wanted something I could setup very quickly and kill as soon as I was done with a simple Ctrl-C.

    -sam