Phoenix.pm: New meeting place
Pablo Velasquez
pablo at dosomething.org
Thu Sep 2 05:06:40 CDT 1999
Hi,
I'm new to the list, and to the Phoenix area.
>I'm game for a meeting. Been a while, but the new place is near my work
>anyway. When and what will we be doing?
Where is the new meeting place?
>I saw a snippet of code I thought was useful so I'll post:
>
>@sorted_by_size =
> map { $_->[0] }
> sort { $a->[1] <=> $b->[1] }
> map { [$_, -s] }
> @files;
I'm a big fan of this piece of code, I use it considerably with our MySQL
db. Here's a variation used with a records retrieval using DBI:
#login to MySQL, etc, now get the stuff
$sth->execute;
$student_records = $sth->fetchall_arrayref;
$sth->finish;
$dbh->disconnect;
#here we sort (alphabetically) the student records
#by "s_alias" whatever that might be...
@{$student_records} =
map { $_->[0] }
sort { lc($a->[1]) cmp lc($b->[1]) }
map {($grab_1, $s_alias) = (@$_); [$_, $s_alias]}
@{$student_records};
foreach $i ( 0 .. $#{$student_records} ) {
$s_datemodified = "$student_records->[$i][0]";
$s_alias = "$student_records->[$i][1]";
$s_total_points = "$student_records->[$i][2]";
$s_student_id = "$student_records->[$i][3]";
#bunch-o-html goes here using the above $s_student_id, yada, yada
print <<ROWS;
ROWS
}
That's it...
-Pablo
More information about the Phoenix-pm
mailing list