Tuesday, July 7, 2009
So I was checking out Daniweb and trying to answer some questions, and I came across this one:
Sort Files by Date
Since I'm slowly learning perl, I thought why not try:
@someData = `command`;
I tried ls -t which happens to be the unix command to list the directory contents in time order.
After some searching for information for a bit about dir so we can see if this works on windows, I found out you can use the dir /od command instead.
Here's the tidbit of code:
@x = `ls -t`;
foreach $x (@x)
$asdf = <>;
The @x holds the return output from the command and the ls -t can be substituted for dir /od on a windows computer.
I then printed each line, which of course can be redirected to a file, or however you wish to use it for handling.
The $asdf = <>; serves as a "pause" in the script so the script doesn't start run and close before you can see anything.
Let me know in the comments if you can run ls -t from your windows computer standard using perl...