my $latest_batch_filename = (`ls Load_* -t -1`)[0]; $latest_batch_filename =~ m/^Load_(\d+)$/; my $latest_batch_number = $1;