[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Beginner's question



On Sat, Feb 05, 2000 at 06:06:02PM +0100, Axel M. Roest wrote:
> __START
> open (WORDSLIST,"WORD LIST for Perl a") || die "can't open wordlist:$!";
> 
> $rex="";
> do {
> 	$rex = MacPerl::Ask("Enter a regularexp", $rex);
> 	while ( defined ( $tester = <WORDSLIST>)) {
> 		chomp ($tester);
> 		if ($tester =~  /$rex/ ) { print "$tester\n"; };
> 	}
> } until length($rex) == 0;
> close (WORDSLIST);
> print "all done\n";
> 
> __END

When the user inputs a null string to end the program, the program will
execute the while loop one last time with a null regex before
exiting.  (This will use the previously successful regex.)

But, since the program never seeks back to the beginning of the file after
the first execution of the while loop, this extra execution won't take very
long.

Ronald

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org