> -----Original Message-----
> From: David Freeman [mailto:[EMAIL PROTECTED]] 
> Sent: Thursday, July 26, 2001 2:47 PM
> To: [EMAIL PROTECTED]
> Subject: Re: "last until eof unless" question
> 
> 
> 
> 
> well, i'm strictly speaking from a grammatical point of view, 
> but it would 
> seem to me that a
> 
> last until eof unless $email;
> 
> would be a valid syntax to go through to the end of the file 
> unless $email 
> was found.

No, sorry, but it isn't. It's basically nonsense. The syntax:

   "expression" until "condition"

Means: 
   1) evaluate "condition"
   2) if condition is false, evaluate "expression" and go back to step 1

The only way this can ever stop is for "expression" to somehow affect the
value of "condition". In your example:

   last until eof

"eof" is the condition. If eof is false, then last is executed. But last is
a loop control construct, which will terminate the loop. So, if eof is
false, the loop immediately exits. If eof is true, the loop immediately
exits. Hence,

   last until eof

makes no sense, Q.E.D.

Next, you cannot use multiple statement modifiers, so:

   foo until bar unless baz

needs to be written as:

   unless (baz) {
      foo until bar;
   }

> i'm not sure that this is what i want to do, but i thought i 
> would see what 
> would happen if i put it in, other than not working. =)
> 
> basically i'm trying to incorporate a way out of the loop i've made.

Well, last is the way out of a loop.

> 
> so after the script has gone through for the first user input 
> and either 
> found it or not, then added it if not found, i want to have something 
> either End the script, or prompt me to look for another user input.
> 
> hope this clarifies what i'm trying to do.

Well, what is the condition that ends the loop? User presses Enter? User
sends Ctrl-D as eof on stdin? Once you figure that out, the statement:

   last if "condition";

will do the trick.

> 
> Thanks!
> 
> 
> ----------------------- code ------------------------ 
> #!/usr/bin/perl -w #Script to add e-mail or domain name to 
> /etc/mail/access file #if not already present.
> 
> use strict;
> #use warnings;
> 
> my $email;
> my $action;
> my $newarray;
> 
> open(NAMES,"/etc/mail/access") || die "Can't open access: 
> $!\n"; while (<NAMES>){
>          ( $email, $action )= split(/\t/);
>          $newarray{$email} = $action;
> }
> close NAMES;
> 
> while(1){
>          print "Look for what domain in spam filter? ";
>          chomp($email=<STDIN>);
>          last until eof unless $email;
>                  if( exists $newarray{$email} ){
>                  print $newarray{$email}, "\n";
>          }else{
>                  print "How you wanna handle this one? ";
>                  my $action;
>                  chomp( $action = <STDIN> );
>                  $newarray{$email} = $action;
> 
>          }
> open(APPEND,">>testfile") || die print "Can't open testfile: 
> $!\n"; #line above to eventually open /etc/mail/access and 
> append $email & $action #to file. print APPEND 
> "$email\t$action\n"; #to show that file has been added close APPEND; }
> 
> eof;
> 
> ------------------------ eof -------------------------------
> 
> 
> At 09:39 PM 7/26/01 +0300, you wrote:
> >[EMAIL PROTECTED]
> 
> David M.R. Freeman
> webmaster sysadmin for MMP, Inc.
> web:            www.woodfreeman.com
> e-mail: [EMAIL PROTECTED]
> phone:  (253) 564-5902
> fax:            (253) 565-1811
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to