Browse Source
Example: run_match_latest.pl gdb will run gdb on the latest non-directory file in the current directory, which is hopefully a core file.master
Duke Leto
14 years ago
1 changed files with 15 additions and 0 deletions
@ -0,0 +1,15 @@ |
|||
#!/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); |
Loading…
Reference in new issue