You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
402 B
15 lines
402 B
#!/usr/bin/perl -w
|
|
|
|
# Run a given program on the newest non-directory in a given directory
|
|
|
|
use strict;
|
|
$|++;
|
|
my $program = shift || die "Must give program to run with latest file";
|
|
my $dir = shift || './';
|
|
|
|
opendir (my $d, $dir) or die $!;
|
|
|
|
my @files = sort { -M $b <=> -M $a } grep { !-d $_ } readdir ($d);
|
|
print "Running: $program " . $files[-1] . "\n";
|
|
system($program, $files[-1]);
|
|
closedir ($d);
|
|
|