terms5 has asked for the wisdom of the Perl Monks concerning the following question:
Thanks!#!/usr/bin/perl use CGI ':standard'; print "Size of party? "; chomp ( $size = <STDIN> ); print "Party name? "; chomp ( $name = <STDIN> ); my @arrayFileQueue; my @arrayPartyNames; my $timeFinal; my @tablesSize = ("tableSize2Two", "tableSize2Three", "tableSize2Four" +, "tableSize2Five", "tableSize2Six", "tableSize2Seven", "tableSize2Eight"); if ($size < 9 && $size > 0) { if ($size == 1) { $randomInt = int(rand 11); $time1 = 30 + $randomInt; unshift(@arrayPartyNames, $name); if (-z "tableSize2One"){ open(FILE, ">tableSize2One"); print FILE "@arrayPartyNames[0]"; close(FILE); $timeFinal = $timeFinal + $time1; print "You have tableSize2One reserved."; } foreach my $i (@tableSize) { elsif (-z "$i") { open(FILE, ">$i"); print FILE "@arrayPartyNames[0]"; close(FILE); $timeFinal = $timeFinal + $time1; print "You have $i reserved"; } } # closes foreach else { print "This is the else statement!"; } } #closes if size equal to 1 } #closes if size is greater than 0 and less than 9
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can an if statement run within a foreach loop?
by GrandFather (Saint) on Apr 21, 2006 at 00:56 UTC | |
by terms5 (Initiate) on Apr 21, 2006 at 04:09 UTC | |
by GrandFather (Saint) on Apr 21, 2006 at 04:31 UTC | |
|
Re: Can an if statement run within a foreach loop?
by GrandFather (Saint) on Apr 21, 2006 at 00:34 UTC |