Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exiting JUST a subroutine

Status
Not open for further replies.

klibby

Programmer
May 30, 2001
51
US
I may have found an answer to my previous question... theres just one thing I need to know in order for it to work...


if you have in a perl script...

<<CODE HERE>>
while 1 = 1 { #just to show the loop continues
&somesubhere;
<<MORE CODE>>
}

sub somethinghere{
<<BUNCH OF IF STATEMENTS>>
if (1 eq 5){ #if statement that comes out false..
???????
}
}


is there a way to exit JUST the subroutine in place of &quot;??????&quot;?... I need it to exit ONLY the subroutine &quot;somethinghere&quot; and go on with the while loop which would then open the subroutine &quot;somethinghere&quot; with another file....


I tried using exit; but I forgot this will end the script so it doesnt do any more...



What it does, is goes through one file (flatfile database), applies the if then statements (filters) to that database, and if it passes all if statements, it displays it.. if not it should not display that one that doesnt match then go on with the rest...

but what it does, is display records that match the filters, but when it hits one that doesnt it completely stops and doesnt go on to the rest that match (because of the &quot;exit;&quot;) what I want to do is use something like exit; but so it exits that subroutine ONLY, not the entire script




 
Actually, I figured another way arround this problem..... however I ran into another problem hehe...
Whats wrong with the following if statement?

if (&input{'lstlvl1'} eq 'Greater Than' && $level < $input{'txtlvl1'}){
$trash=&quot;1&quot;;
}


im thinking its the < ... since equals is &quot;eq&quot; and not = in perl..... im guessing theres something replacing &quot;<&quot;? if so what is it? (by < i mean less than)
 
rofl.... i always seem to find whats wrong AFTER i post the problem here.... found it, wasnt looking close enough... i had an & where a $ should be
 
FYI, if you are doing a NUMERIC compare you would use <, <=, >, <=, !=, or == (note TWO equals). If you are doing a STRING compare you would use lt, le, gt, ge, ne, or eq.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top