#!/usr/bin/perl -w use strict; my $epsilon = 7; sub orders_of_the_day { print "Orders of the day:\n"; print "==================\n"; order_list(); } my @actors = ("Grocer1", "Grocer2", "Warehouse1", "Warehouse2", "Market1", "Market2"); my @actions = ("buy", "sell", "deliver", "pick up"); my @acted = ("rice", "asparagus", "lettuce", "apples", "oranges", "bread", "celery"); orders_of_the_day(); sub order_list { while(1) { my $option = int(rand(100)); if($option == $epsilon) { print "EPSILON\n"; return(); } order(); } } sub order { print "ORDER: "; pick_actor(); pick_action(); pick_acted(); print "\n"; } sub pick_actor { my $chances = @actors; my $option = int(rand($chances)); print " $actors[$option]"; } sub pick_action { my $chances = @actions; my $option = int(rand($chances)); print " $actions[$option]"; } sub pick_acted { my $chances = @acted; my $option = int(rand($chances)); print " $acted[$option]"; }