|Do you know where your variables are?|
Excel-like sort for multiple fields unix 'ls -l' outputby cmv (Chaplain)
|on Jul 08, 2010 at 16:25 UTC||Need Help??|
cmv has asked for the
wisdom of the Perl Monks concerning the following question:
I have the need to allow a GUI user to select various ways to sort multi-line text output from a (SunOS based) 'ls -l' command (think auto-sort on excel).
Given the ls format as follows:
In my opinion, they may choose to sort on any field except file permissions (but then again...), here's a list from right-to-left (as I understand them) and how they should be sorted:
I have all the data in a list (it comes from a remote host, so I can't access the file information directly from perl).
My current plan is to create a sub that is called like this:
This sub should be smart enough to do the right thing when sorting the various fields. I'm looking for advice on how to design it (or pointers to an existing sub that does this, or CPAN modules that may be helpful).
So far, my investigations initially led me to Sort::Fields which gives me a nice framework to do field sorting on a list of text, but would break down on the timestamp stuff (I could pre-process that to shoehorn it to work with this module).
Am I on the right track here, or is there something better I should be considering? I have some fears about the following:
Any thoughts or suggestions are appreciated!