in reply to for loop
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: for loop
by CharlesClarkson (Curate) on Jun 22, 2001 at 08:01 UTC | |
by Abigail (Deacon) on Jun 22, 2001 at 11:55 UTC | |
|
Re: Re: for loop
by Anonymous Monk on Jun 22, 2001 at 14:03 UTC |