in reply to Where am I going wrong with printing flatfile db records in alphabetical order?
To be honest, your code really doesn't make much sense. Here's how I'd do it:
open DATABASE, $mydata or die "Can't open $mydata: $!\n"; flock DATABASE, LOCK_EX or die "Can't lock $mydata: $!\n"; my @list = <DATABASE>; close DATABASE; # which also unlocks it @list = sort { substr($a, 0, 8) cmp substr($b, 0, 8) } @list;
At the end of this code, @list contains the data in sorted order.
Update: Ovid is right, of course. Corrected.
--"The first rule of Perl club is you don't talk about Perl club."
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(Ovid) Re(2): Where am I going wrong ?
by Ovid (Cardinal) on Oct 29, 2001 at 21:04 UTC |