TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:2586] perl question



On Sun, 6 Dec 1998, Ben Luey wrote:

> In perl is there a good way to write a script such that
> 
> if A and if B, then C
> if not A then C
> if A and not B then nothing?
> 
> I'd like to write the script without typing C in twice. Also, if A, then I
> need to to some stuff to determine if B is true, so I can't do a combined
> if (A and B).

simplicity itself....

if (A) {
	if B {
		C ();
	}
}

if (!A) {
	C ();
}

sub C {
	do stuff;
}

                                      - Dave

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  Name:  David Finton                  | "Don't be afraid you'll make really
 Email:  dfinton@d.umn.edu             |  dumb mistakes.  Sometimes really
   Web:  http://www.d.umn.edu/~dfinton |  dumb mistakes are the only way to
                                       |  learn the really fundamental and
                                       |  important lessons in life."
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-