Don't ask to ask, just ask | |
PerlMonks |
Re: (2) Flawless Script problems?by AcidHawk (Vicar) |
on Mar 13, 2003 at 08:35 UTC ( [id://242618]=note: print w/replies, xml ) | Need Help?? |
Perhaps a brief explination is in order. When you enter the option f (for Find) and ask who you want to look for. The answer is captured into $f. I have then run the &find subroutine passing it the name that was received ie: &find($f). This function I enclosed in an if not block to check the return of &find. So if the return, from &find, is 0(fail) then &find could not find a matching name otherwise &find returned a 1(pass). The &find subroutine is easy to explain... First you set a var to 0 (ie: $rc = 0;) this is what will be returned if NO match is found. Next we make a local var for &find = the name ($f) we sent to the sub-routine. This is done using shift. After that, all we do is, check if foreach key in the hash, equals the name we entered (now $f in &find). If it matches we set $rc to 1 and stop searching through the hash. Hope that doesn't comfuse you further. Of all the things I've lost in my life, its my mind I miss the most.
In Section
Seekers of Perl Wisdom
|
|