Update restaurant list.
[restaurants.git] / restaurants.pl
blobebcd361a73737e2cbda9f1146ebded9e94ad5998
1 #!/usr/bin/perl
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 use warnings;
17 use strict;
19 use Getopt::Long;
21 my @restaurant_list = (
22 '4S Ranch (Outside Patio)',
23 'Akai Hana',
24 'Athens',
25 'Baja Fresh',
26 'Bamboo Fresh',
27 'Boston Market',
28 'Brett\'s BBQ',
29 'California Pizza Kitchen',
30 'Cheeburger Cheeburger',
31 'Chili\'s',
32 'China Fun',
33 'Coco\'s',
34 'Daphne\'s Greek Cafe',
35 'El Torito\'s',
36 'Elephant Bar',
37 'Fire House Pizza',
38 'Grazianos',
39 'Island\'s',
40 'Joey\'s Smokin\' BBQ',
41 'Kelly\'s Public House',
42 'King Taco Loco Donalds In-N-Out a Box Jr\'s',
43 'L&L Hawaiian Barbecue',
44 'Little Tokyo',
45 'Mama Cella\'s',
46 'Marie Callender\'s',
47 'Olive Garden',
48 'Panda Buffet',
49 'Panera',
50 'Passage To India',
51 'Pat and Oscars',
52 'Pearl',
53 'Pegasus',
54 'Pei Wei',
55 'Pho',
56 'Pick Up Stix',
57 'Quick Wok',
58 'RB Sushi',
59 'Rubio\'s',
60 'Souplantation',
61 'Spices Thai',
62 'Stir Fresh',
63 'Subway',
64 'ThaiGo',
65 'ToGo\'s',
66 'Wahoo\'s',
67 'Wings N Things');
69 sub main {
70 my $pick = 1;
71 my $quiet = 0;
72 my @random_restaurant_list;
74 GetOptions(
75 'pick=i' => \$pick,
76 'quiet!' => \$quiet,
77 'silent!' => \$quiet);
79 if(1 > $pick) {
80 print "Usage: . . . \n";
81 return -1;
84 if(1 != $quiet) {
85 print "Karen's Restaurant Selector\n\n";
88 # Create list
89 my $done = 0;
90 my $num_of_loops = 0;
91 do {
92 $num_of_loops++;
93 my $restaurant_name = $restaurant_list[rand @restaurant_list];
94 my $on_list = 0;
95 foreach (@random_restaurant_list) {
96 if ($_ eq $restaurant_name) {
97 $on_list = 1;
100 if (0 == $on_list) {
101 push @random_restaurant_list, $restaurant_name;
103 if($pick == scalar @random_restaurant_list) {
104 $done = 1;
107 # If we have tried to pick restaurant twice as many times as asked and
108 # still don't have enough, just exit.
109 if($num_of_loops >= $pick * 2) {
110 $done = 1;
112 } until(1 == $done);
114 # Print list
115 @random_restaurant_list = sort @random_restaurant_list;
116 my $num_restaurants = scalar @random_restaurant_list;
117 for(my $i = 0; $i < $num_restaurants; $i++) {
118 print $random_restaurant_list[$i];
119 if($i + 1 != $num_restaurants) {
120 print ", ";
123 print "\n";
125 return 0;
128 exit(main());