Blob


1 use v5.14;
3 my $output_lines = 0;
4 my $records = $ARGV[0] // 50;
6 my $crew_items = [ qw( flares rope GPS patch_kit marine_radio ) ];
7 my $luxuries = [ qw( TV telephone_dialer corkscrew valet golf_bag ) ];
8 my $tools = [ qw( screwdriver duct_tape WD40 thermocouple batteries ) ];
9 my $common = [ qw( cheese steak_knife umbrella fork shampoo cheetos) ];
11 my $crew_wants = {
12 Gilligan => [ $crew_items ],
13 Skipper => [ $crew_items ],
14 Thurston => [ $luxuries ],
15 Ginger => [ ],
16 'Mary Ann' => [ ],
17 Professor => [ $tools ],
18 };
20 foreach my $value ( values $crew_wants ) {
21 push $value, $common;
22 }
24 while( $output_lines < $records ) {
25 state %Seen;
26 my $castaway = ( keys %$crew_wants )[ rand keys %$crew_wants ];
27 my $castaway_array = $crew_wants->{$castaway};
28 my $select_from = $castaway_array->[ rand @$castaway_array ];
30 my $item = $select_from->[ rand @$select_from ];
32 next unless $item;
33 next if $Seen{$castaway}{$item}++;
35 $output_lines++;
36 say join "\t", $castaway, $item;
37 }