If I did need the array (in other parts of the program), I would write the loop as:open my $file => "<", $ipfile or die "Open: $!"; my $found; while (<$file>) { next if -1 == index $_ => $remote_addr; print "Added new guest\n"; $found = 1; last; } print "Guest not found\n" unless $found;
my $found; foreach (@ipfconts) { next if -1 == index $_ => $remote_addr; print "Added new guest\n"; $found = 1; last; } print "Guest not found\n" unless $found;
-- Abigail
In reply to Re: for loop
by Abigail
in thread for loop
by s0ttle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |