Posted by admin | Posted in Cookbooks for Bar B Cues | Posted on 04-06-2008
Tags: choice menus cookbook, cooking, css, food, million menus cookbook, recipes, webdesign

sorting in perl..part2?
wen i call this function
print pre Dumper %elements; #i get this back.
$VAR1 = ’25′; #<-id
$VAR2 = {
'price' => ’45.00′,
‘title’ => ‘asdasdasd’
};
$VAR3 = ’4′;
$VAR4 = {
‘price’ => ’44.95′,
‘title’ => ‘Java Servlet & JSP Cookbook’
};
$VAR5 = ’1′;
$VAR6 = {
‘price’ => ’103.00′,
‘title’ => ‘Operating Systems Design and
Implementation, 3/E’
};
.so in order to display the title and the price in a pop up menu. i do this..
my @values;
my %labels;
foreach (keys %elements)
{
push(@values, $_);
my $title = $elements{$_}{title};
my $price = $elements{$_}{price};
$labels{$_} = “$title ($$price)”;
}
print
popup_menu( {
name => ‘id’,
values => @values,
labels => %labels,
ononchange => ‘submit()’, # JavaScript event handler
} );
#how wud i have the pop up menu sorted by the title?
Firstly, sorting a hash isn’t exactly the most ideal situation, it would be better if each item was a hashref in an array:
@books = (
{ id => 1, title => ‘foo’, price => ’2.99′ },
# etc…
);
however, it can be done by using the key to look up the title in the hash via a custom sort routine (e.g $books{ $a }->{ title }).
—
use strict;
use warnings;
use CGI qw( :all );
my %books = (
4 => {
‘price’ => ’44.95′,
‘title’ => ‘Java Servlet & JSP Cookbook’
},
1 => {
‘price’ => ’103.00′,
‘title’ => ‘Operating Systems Design and Implementation, 3/E’
},
25 => {
‘price’ => ’45.00′,
‘title’ => ‘asdasdasd’
}
);
my( %labels, @values );
my @items = sort { lc $books{ $a }->{ title } cmp lc $books{ $b }->{ title } } keys %books;
foreach my $key ( @items ) {
my $item = $books{ $key };
push @values, $key;
$labels{ $key } = sprintf( ‘%s ($%s)’, $item->{ title }, $item->{ price } );
}
print popup_menu( {
name => ‘id’,
values => @values,
labels => %labels,
ononchange => ‘submit()’
} );
Weeknight Meals, Mix & Match Menus cookbook WINNERS!
|
|
Recipe and Takeout Menu Organizer Binder $9.97 Keep your takeout drawer orderly with this menu and recipe organizer. It is designed for simplicity inside a three ring binder. This organizer includes 20 top-loading pocket pages, 8 decorated tabbed divider pages, and 1 sheet of 39 preprinted and 9 blank label stickers with categories like meats, vegetables, salad, Mexican, French and Greek. With a stylish cover this binder is sure to keep all yo… |
|
|
Demy Kitchen Safe Touchscreen Recipe Reader $299.95 Digital Recipe Reader… |
|
|
CR Gibson Deluxe Take Out Menu Organizer $27.00 Cr Gibson Good to Go Take-Out Menu OrganizerMeasures 10 1/2 ôw x 11 3/4 ôh x 2öd8 Tabbed pocket dividers, organized by cuisineSticker sheet for easy personalizationVinyl zipper pouch for coupon storage4 x 6 note pad for taking group ordersIncluded space for frequently dialed numbersHandy tip calculator… |
|
|
Menus and Music, Gourmet Cookbook and Music CD Volume XVII $6.78 The Rossetti String Quartet: Nina Bonar, violin; Henry Gronnier, violin; Tom Diener, viola; Eric Gaenslen, cello Artwork Works by more than 60 major artists Vermeer Monet Van Gogh Picasso O Keeffe Warhol Museum Cafés and Arts Inspired Recipes from Favorite Museum Cafés Chamber Music by the Rossetti String Quartet Art from America s Great Museums By Sharon O Connor Muse… |
|
|
Dinner Menu Cookbook [VHS] $235.00 … |
|
|
Episode Two $1.99 … |
|
|
Knock Knock Takeout Menu Organizer $19.99 The Takeout Menu Organizer proudly acknowledges the fact that most of us don’t cook every night-or any night. This revamped modern-day recipe box conveniently stores everything necessary to feed oneself via telephone or Internet in one contained place. Includes handy meal-rating stickers, tipping guide, helpful ordering advice, frequently called numbers list, and so much more. An essential to… |
|
|
Food Lovers Fat Loss System Kit Unlike a traditional diet where you deprive yourself of the foods you love, The Food Lovers Fat Loss System is a more practical approach to weight loss that teaches you how to use the foods you love to lose fat. Developed under the direction of certified nutritionist and respected author Robert Ferguson, M.S., C.N., Food Lovers is a simple day-by-day plan that, in just 21 days, will teach you how … |
