in reply to Category List
This sorts them left -> right, top -> bottom. If you want the precedence the other way round, you need to work on things a bit more.#!/usr/bin/perl -w use strict; # sorted list my @list = sort qw(stereo tv monitor scanner keyboard mouse banana); # add extra element if odd length, so next statement doesn't break push @list, '' if @list%2; # turn array into a hash my %list = @list; # text - need 'if' to avoid empty bullet if odd No. elements for (sort keys %list) { printf("- %-20s", $_); printf("- %-20s", $list{$_}) if $list{$_}; print "\n"; } # html (snippet) print qq(\n<table>\n); for (sort keys %list) { printf("<tr><td>%s</td><td>%s</td></tr>\n", $_, $list{$_}); } print qq(</table>\n);
hth
cLive ;-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Category List
by Kanji (Parson) on Dec 02, 2001 at 13:31 UTC |