After looking at you code for a while I trimmed it down to the following code. I suggest you use it as a starting point for rephrasing your question.
#!/usr/bin/perl use strict; use warnings; use CGI ':standard'; print "Size of party? "; chomp (my $size = <DATA> ); print "Party name? "; chomp (my $name = <DATA> ); my @arrayPartyNames; my @tableSize = ( "tableSize2One", "tableSize2Two", "tableSize2Three", "tableSize2Fo +ur", "tableSize2Five", "tableSize2Six", "tableSize2Seven", "tableSize2E +ight" ); exit if $size > 8 || $size < 1; my $randomInt = int(rand 11); my $time1 = 30 + $randomInt; unshift(@arrayPartyNames, $name); foreach my $table (@tableSize) { next if -z $table; open FILE, '>', $table; print FILE "$arrayPartyNames[0]"; close(FILE); print "\nYou have $table reserved.\n"; last; } __DATA__ 2 Joe
Prints:
Size of party? Party name? You have tableSize2One reserved.
In reply to Re: Can an if statement run within a foreach loop?
by GrandFather
in thread Can an if statement run within a foreach loop?
by terms5
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |