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

ELSUNLESS??? if, elsif, else >> unless, elsunless, else?? 1

Status
Not open for further replies.

adelante

Programmer
May 26, 2005
82
DK
You can do this:
Code:
if(){
  }
elsif(){
  }
elsif(){
  }
else{
  }

... but what about unless??
can you only do this:
Code:
unless(){
  }
else{
  }
or is there a similar elsunless??
 
should work:

unless(){
}
elsif(){
}
else{
}

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Or if you're having problems, why not just use either the '!' or 'not' operator? They have different precedence - so you may need to be careful with which you use, but this works:
Code:
if(! TRUE){
    # do stuff
} elsif(not TRUE){
    # do some other stuff
} else{
    # do something else
}
 
Thanks, I will try it. My brain capacity is too small right now to figure out if the elsif is an "elsIF" or "elsUNLESS"

But I will try it next time. Thanks alot!


Btw how do you turn this into an IF instead of UNLESS:

Code:
my $test=234;
unless($test){
   print"I'm print something here";
   }

I sometimes use it to check if a record is already in the database, but if I write this, i get an error:
Code:
if($test eq ""){
   }

if($test == ""){
   }
 
Code:
my $test = 234;
if (! $test){
   print "\$test is not defined";
}
else {
   print "\$test is defined: $test";
}

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Thanks!!!!!!!!!!!!!!!!!!

I have been doing stupid things for years... :(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top