good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: most efficient buffer sortby serf (Chaplain) |
on Dec 14, 2005 at 12:15 UTC ( [id://516593]=note: print w/replies, xml ) | Need Help?? |
I have been a bit naughty in assuming that it's OK to use
to replace your: Because if you have multiple spaces immediately after $second they will be lost - but as you're putting the data into HTML table cells this shouldn't be an issue. NB: I used split(/\s+/, $_) and not split(' ', $_) because you were matching /^(\w+), which may just have been for efficiency and anchoring, but I don't know that you didn't need to make sure that there was no leading white space on the line in the input file. I have not used GrandFather's map because I needed to do quite a lot to the elements returned by the sort (the tests on $sort and the sprintf) and it looked like it was going to be messy and possibly difficult trying to fit it all in there. I like map, but I tend to shy away from using it for more than the most basic usage - I know 95%+ of the people I've ever worked with who have to deal with Perl would not be able to understand how the map worked, but could all unroll a foreach loop if they needed to change the code after I had moved on to my next contract.
In Section
Seekers of Perl Wisdom
|
|