Perl-Sensitive Sunglasses | |
PerlMonks |
sort on numbers embedded in textby d4vis (Chaplain) |
on Oct 09, 2000 at 19:04 UTC ( [id://35912]=perlquestion: print w/replies, xml ) | Need Help?? |
d4vis has asked for the wisdom of the Perl Monks concerning the following question:
Howdy, I've got a data file that's resisting all of my attempts to sort it correctly. Unfortunately, my skill with Perl is such that even a simple sort is still a challenge, much less a numerical sort on data that's embedded in text strings, thusly; (three space seperator) As you can see, there are 3 formats that I need ordered. Those that are ddd-FMT-FMT need a numerical sort. Those that are BLOGOddd-FMT-FMT need to be sorted seperately, but also numerically. Everything else can be sorted normally, but I'm going to run the output through a 20 year old ATEX system, so I need to retain the -FMT-FMT and BLOGO tags. I've read the sort docs, to no avail. So far, my (somewhat feeble) attempts to get this done have all been variations on reading the data into an array and trying various sort and s/// combinations. Most of the code I've tried looks something like this:
Am I approaching this all wrong? Should I be looking at split or map maybe? The prognosis for me figuring this one out anytime soon seems slim, so any help/guidance would be greatly appreciated. a fronte praecipitium a tergo lupi
~scribe d4vis
Back to
Seekers of Perl Wisdom
|
|