[PLUG] Grab the most recent file in perl?

Felix Lee felix.1 at canids.net
Thu Feb 13 15:21:01 UTC 2003


srau at rauhaus.org (Stafford A. Rau):
> But no, I shouldn't have to shell out for pretty much
> anything these days.

this is the wrong philosophy.  the point of shell
programming is to let you solve common problems quickly by
giving you simple and powerful ways of combining existing
tools.

'ls -t' is the tool that answers the question you want.  why
spend the time and effort re-inventing the wheel?  don't you
have more important things to do?

one possible answer is performance.  in general, until
something gets executed a million times or so, performance
is not very interesting, it's not worth your time to
optimize.

another possible answer is reliability.  'ls -t' runs into
problems if you have filenames with newlines in them.

> for (</var/local/flows/ft*>) {
> 	$file_hash{$_} = (stat $_)[9];
> }
> and then sort by the hash by value? I'm betting there's a
> better way, and am happy to hear suggestions.

yes, that's ok.  what do you mean by "better"?  faster
execution, less memory use, more reliable, easier to read,
easier to write, more impressive, or something else?
--




More information about the PLUG mailing list