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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

die ( ) 1

Status
Not open for further replies.

JohnLucania

Programmer
Oct 10, 2005
96
US
How do you put die () in this case? if !CheckSeq (); then, sub 2nd and sub 3rd don’t need to be called and don’t need to print.

sub CheckSeq {
return scalar grep /[abceABDE]/, @SeqChar;
}

sub 2nd{
}
sub 3rd {
}

print "1. Your input contains valid sequence.\n"
if CheckSeq ();
print "1. Your input contains invalid sequence.\n"
if !CheckSeq ();
print .....
2nd ();
print .....
3rd ();
 
You are very close - just use
Code:
die "1. Your input contains valid sequence.\n" if CheckSeq ();
die "1. Your input contains invalid sequence.\n" if !CheckSeq ();
print .....
    2nd ();
print .....
    3rd ();
assuming [tt]die[/tt] is what you want. It prints to STDERR, runs object destructors, END blocks, closes and flushes filehandles and then exits.

Yours,

fish


["]As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs.["]
--Maur
 
Shouldn't it be?

"1. Your input contains valid sequence.\n" if CheckSeq ();
die "1. Your input contains invalid sequence.\n" if !CheckSeq ();

I need die () when it is invalid.

With this:
die "1. Your input contains invalid sequence.\n" if !CheckSeq ();

It still prints:
print .....
2nd ();
print .....
3rd ();

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top