caciqueman has asked for the wisdom of the Perl Monks concerning the following question:
then it goes on to substitute the $lname for %%name%% etc, and print it to a html template (which works fine). Problem is, the script prints in reverse entry order instead of alphabetical. Any suggestions for a new kid that is really lost. ? Shaysub view_it { open (DATABASE, "$mydata") || &CgiDie ("I am sorry, but I was not able + to open the data file."); flock (DATABASE, 2); @list = <DATABASE>; flock (DATABASE, 8); close (DATABASE); foreach $list (@list) { ($lname, $fname, $email, $phone, $message, $ip, $date) = split(/\|\|/, + $list); &byName; $test = 1; &print_it; } } sub byName { # sort database by first 8 of last name ((substr $a, 0, 8) cmp (substr $b, 0, 8)); } $i = 0; # loop counter while (<>) { $filerecs[$i++] = $_; } @sorted_recs = sort byName @filerecs
Edit kudra, 2001-10-30 Changed title
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Where am I going wrong ?
by davorg (Chancellor) on Oct 29, 2001 at 19:44 UTC | |
by Ovid (Cardinal) on Oct 29, 2001 at 21:04 UTC | |
|
Re: Where am I going wrong ?
by Albannach (Monsignor) on Oct 29, 2001 at 19:51 UTC | |
by caciqueman (Novice) on Oct 29, 2001 at 22:31 UTC | |
by dmmiller2k (Chaplain) on Oct 30, 2001 at 01:51 UTC | |
|
Re: Where am I going wrong ?
by jbert (Priest) on Oct 30, 2001 at 14:03 UTC |