stupidius has asked for the wisdom of the Perl Monks concerning the following question:
In searching a flatfile database, can I stop a while loop when i find what I'm looking for? Does the "last" actually stop this loop?
while(<ACCOUNTS>) { my %account = split(/::/, $_); if( $account{"MASTER"} eq $_[0] ) { foreach my $key(keys(%account)) { #do something here } last; } }
Edited by Chady -- restored original contents and title.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can a while loop be stopped with "last"?
by rjbs (Pilgrim) on Jul 14, 2004 at 02:40 UTC | |
by beable (Friar) on Jul 14, 2004 at 02:45 UTC | |
|
Re: Can a while loop be stopped with "last"?
by ysth (Canon) on Jul 14, 2004 at 02:34 UTC | |
|
Re: Can a while loop be stopped with "last"?
by pg (Canon) on Jul 14, 2004 at 03:23 UTC | |
by ysth (Canon) on Jul 14, 2004 at 03:33 UTC | |
|
Re: Can a while loop be stopped with "last"?
by Juerd (Abbot) on Jul 14, 2004 at 08:25 UTC | |
by stupidius (Initiate) on Jul 15, 2004 at 02:23 UTC | |
by Juerd (Abbot) on Jul 15, 2004 at 07:43 UTC | |
| |
|
Re: Can a while loop be stopped with "last"?
by ercparker (Hermit) on Jul 14, 2004 at 02:43 UTC |