Conditional Control Statements : If « Statement « Perl

Perl
1. Array
2. CGI
3. Class
4. Data Type
5. Database
6. File
7. GUI
8. Hash
9. Language Basics
10. Network
11. Regular Expression
12. Report
13. Statement
14. String
15. Subroutine
16. System Functions
17. Win32
18. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Perl » Statement » If 
Conditional Control Statements
   

#    if (Expression) {Code Segment}
#    if (Expression) {Code Segmentelse {Code Segment}
#    if (Expression) {Code Segmentelsif {Code Segment... else {Code Segment}

    #!/usr/local/bin/perl -w

    while (<STDIN>)
    {
       chomp;

       if ($_ < 10)
       {
          print "$_ is less than 10.\n";
       }
       elsif ($_ < 20)
       {
          print "$_ is between the values of 10 and 19.\n";
       }
       else
       {
          print "$_ is greater than or equal to 20.\n";
       }
    }

   
    
    
  
Related examples in the same category
1. A program containing a simple example of an if statement.
2. A program that uses the if-else statement.
3. A program that uses the if-elsif-else statement.
4. Conditional Modifiers and print
5. Conditional Modifiers: The if Modifier
6. Extend the if statement to include an else block
7. If and else
8. If start with - no repeat
9. If statement and integer comparsion
10. If statement in a while statement
11. If statement ladder
12. If statement with else
13. If statement with scalar variable
14. Nest if statement into for loop
15. Perl has a number of string comparison operators you can use in if statements.
16. Plural format and ternary operator
17. Plural message
18. Plural output with if statement
19. The if Construct
20. The if/else Construct
21. The if/elsif/else Construct
22. Use an elsif statement to check if a different condition is true
23. Use if statement to check the integer value
24. Using if statement to check if a variable has been defined
25. Using if statement to check if a variable is zero
26. Using if statement to check the number entered from keyboard
27. Using if statements with relational and equality operators
28. Using the equality-comparison operator to compare two numbers entered at the keyboard.
29. Using the if elsif statement to check the number entered from keyboard
30. if in a while loop
31. if scope
32. if statement
33. if/else statement
34. if/elsif statement
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.