Monday, December 24, 2012

Perl 의 if, elsif, unless 문

 $age = ; # whatever ??  
 if ($age < 16)  
  {  
   print "Hi, Junior\n";  
  }  
 elsif ($age < 17)  
  {  
   print You can ????\n";  
  }  
 elsif ($age < 18)  
  {  
   print You can learn to drive\n";  
  }  
 else  
  { print "Go and Vote and then have a beer.\n";  
  }  
else if 가 아니라 elsif 임.
 $age = ... ;   
 unless ($age < 18)  
 {  
      print "Go and Vote and then have a beer.\n";  
 }  
if not 이 아니라 unless 임.
unless 에도 else 사용 가능.

If/Unless statement
키워드 : elseif

No comments:

Post a Comment