in reply to File search
my $latest_batch_filename = (`ls Load_* -t -1`)[0]; $latest_batch_filename =~ m/^Load_(\d+)$/; my $latest_batch_number = $1;
In this case, `ls Load_* -t -1` will grab a list of files sorted by time. (If you're looking for the highest batch number and that's not correlated with the timestamps on files, you'll have to sort differently.) By extracting the zeroth element of the resulting list, you get the most recently modified one. The regex extracts the actual batch number from that filename.
This assumes you're using a Unix-ish OS; in DOS/Windows you'd go with something more like `dir Load_* /o:-d/b`. Anyway, you can try various commands in your shell until you get the results you want, then use backticks to slurp that into your Perl script.
|
|---|