#!D:\Perl\bin\perl.exe use CGI qw(:standard); |
# realsearch.pl # # Sample code for conducting a search for the perfect # wine. Since I don't actually have any access to real # wines, I just created some random responses. |
print header(-'Cache-Control'=>'max-age=604800'); srand; |
# pseudo-real response |
$winename{'all'} = "Some wine";
$winename{'red'} = "Some red wine";
$winename{'rcab'} = "Cabernet";
$winename{'rmer'} = "Merlot";
$winename{'rsir'} = "Petite Sirah";
$winename{'rsan'} = "Sangiovese"; |
$winename{'rzin'} = "Zinfandel";
$winename{'wht'} = "Some white wine";
$winename{'wchr'} = "Chardonnay";
$winename{'wblc'} = "Pinot Blanc";
$winename{'wgrs'} = "Pinot Gris";
$winename{'wsau'} = "Sauvignon Blanc"; |
@vineyard = ("Fru-fru gardens", "Grapes R Us",
"Da Wine Haus", McWine", "Squashed Grape",
"Wine Hut", "Wine-in-a-box", "Fancy pants",
"Grapealicious!"); |
@descriptions = qw(Dry Fruity Sweet Full-bodied
Light-bodied Tart Flavorful Good Excellent
tasty yummy icky); |
@odors = qw(courant blackberry peach pear cherry
orange sulfur apple lemon raspberry); |
print <<End_of_Beginning; |
<HTML>
<HEAD>
<META name="HandheldFriendly" content="true">
<TITLE>Search Results</TITLE>
</HEAD>
<BODY>
Results from your search: |
End_of_Beginning |
# Create three wines... |
for ($i = 0; $i < 3; $i++) { |
print '<table width="100%" border="0"
cellspacing="1" cellpadding="0">'. "\n";
print '<tr> <td colspan="2">'. "\n";
print '<div align="center"><b>'; |
# Print the vineyard, type of wine, and year
print $vineyard[int(rand(@vineyard))];
print ' '. $winename{param('variety')}. ', '.
(int(rand(50)) + 1950). '</b></div>'. "\n";
print '</td></tr>'. "\n"; |
# Print a random price based on the "cost" parameter
$_ = param('cost');
($low, $hi) = /(\d+)-(\d+)/;
print '<tr><td width="20%">Cost</td><td width="80%"> $';
print (int(rand($hi - $low)) + $low). '</td></tr>'. "\n"; |
# Generate some random adjectives to the wine's odor
# and overall description. |
print '<tr><td width="20%">Descriptions</td><td width="80%"> ';
print $descriptions[int(rand(@descriptions))]. ', ';
print $descriptions[int(rand(@descriptions))]. '</td></tr>'. "\n";
print '<tr><td width="20%">Odors</td><td width="80%">';
print $odors[int(rand(@odors))]. ', '.
$odors[int(rand(@odors))]. '</td></tr>'. "\n";
print '</tr> </table>'. "\n"; |
print '</BODY></HTML>'. "\n\n"; |
} |
# # Copyright (c) 2007, iAnywhere Solutions, Inc., # all rights reserved. # # IANYWHERE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT # THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR # PURPOSE, OR NON-INFRINGEMENT. IANYWHERE SHALL NOT BE # LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT # OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR # ITS DERIVATIVES. |
| Send feedback about this page using email. | Copyright © 2008, iAnywhere Solutions, Inc. |