Changes

From SME Server
Jump to navigationJump to search
192 bytes added ,  16:12, 28 December 2013
Line 231: Line 231:  
=== Conditional and looping constructs ===
 
=== Conditional and looping constructs ===
   −
Perl has most of the usual conditional and looping constructs. As of Perl 5.10, it even has a case/switch statement (spelled given /when ). See Switch Statements in perlsyn for more details.
+
Perl has most of the usual conditional and looping constructs. As of Perl 5.10, it even has a case/switch statement (spelled '''given''' /'''when''' ). See [http://perldoc.perl.org/perlsyn.html#Switch-Statements Switch Statements in perlsyn] for more details.
    
The conditions can be any Perl expression. See the list of operators in the next section for information on comparison and boolean logic operators, which are commonly used in conditional statements.
 
The conditions can be any Perl expression. See the list of operators in the next section for information on comparison and boolean logic operators, which are commonly used in conditional statements.
Line 251: Line 251:  
         }
 
         }
   −
     This is provided as a more readable version of if (!condition).
+
     This is provided as a more readable version of '''if (!condition)'''.
    
     Note that the braces are required in Perl, even if you've only got one line in the block. However, there is a clever way of making your one-line conditional blocks more English like:
 
     Note that the braces are required in Perl, even if you've only got one line in the block. However, there is a clever way of making your one-line conditional blocks more English like:
Line 269: Line 269:  
         }
 
         }
   −
     There's also a negated version, for the same reason we have unless :
+
     There's also a negated version, for the same reason we have '''unless''' :
    
         until ( condition ) {
 
         until ( condition ) {
Line 275: Line 275:  
         }
 
         }
   −
     You can also use while in a post-condition:
+
     You can also use '''while''' in a post-condition:
    
         print "LA LA LA\n" while 1; # loops forever
 
         print "LA LA LA\n" while 1; # loops forever
Line 287: Line 287:  
         }
 
         }
   −
     The C style for loop is rarely needed in Perl since Perl provides the more friendly list scanning foreach loop.
+
     The C style for loop is rarely needed in Perl since Perl provides the more friendly list scanning '''foreach''' loop.
 
==== foreach ====
 
==== foreach ====
   Line 299: Line 299:  
         }
 
         }
   −
     The foreach keyword is actually a synonym for the for keyword. See Foreach Loops in perlsyn.
+
     The '''foreach''' keyword is actually a synonym for the for keyword. See [http://perldoc.perl.org/perlsyn.html#Foreach-Loops Foreach Loops in perlsyn].
 +
 
 +
For more detail on looping constructs (and some that weren't mentioned in this overview) see [http://perldoc.perl.org/perlsyn.html perlsyn].
   −
For more detail on looping constructs (and some that weren't mentioned in this overview) see perlsyn.
   
=== Builtin operators and functions ===
 
=== Builtin operators and functions ===
  

Navigation menu