Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Sort an array which contains date formatted elements

by snopal (Pilgrim)
on Jul 17, 2007 at 14:45 UTC ( #627038=note: print w/ replies, xml ) Need Help??


in reply to Sort an array which contains date formatted elements

If you can be assured that your files are not altered after the log moves on (big assumption that must be verified), you might just use a 'stat' mtime as your sort key.

Also, if you want to do a system call using backtics, you can let the file system sort your files for you (assuming UNIX).

my $files = `/bin/ls -1tr $dir`; my @files = grep { ! -d "$dir/$_" and ! /user.log/ } split /\n/, $file +s;


Comment on Re: Sort an array which contains date formatted elements
Download Code
Re^2: Sort an array which contains date formatted elements
by msk_0984 (Friar) on Jul 20, 2007 at 06:40 UTC
    Respected monks

    Thank You all for your prompt replies and my problem has been sorted out. I could really learn a lot from each and every idea that has beem posted to me. Here in Perlmonks site I have evoled myself and have learnt a lot.

    Snopal

    This is also a very good idea to sort the files up on the modification time as the latest file is the one which is modified according to the dates.

    This also has done the trick for me but can you please explain me wat does "1" do there becos since -t and -r we use them for the modification time and to reverse sort. But "1" i was not able to find wat does 1 do ...

    Any ways thank uo very much for ur solution too.

    Sushil Kumar

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://627038]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2014-08-29 19:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (287 votes), past polls