The easiest way to do what you want is to use grep to winnow out files beginning with `PC', then sort them by modification time and pick the first one from that sorted list.
opendir( FOO, $somedir ) or die "Can't opendir $somedir: $!\n"; my @PC_dirs = grep /^PC/ and -d "$somedir/$_", readdir( FOO ); closedir( FOO ); my $most_recent = (map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_, -M "$somedir/$_" ] } @PC_dirs)[0];
In reply to Re: greping from lists
by Fletch
in thread greping from lists
by suekawar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |