Thursday, March 6, 2008

Learning Perl, 4th Edition Notes 0x9

Learning Perl, 4th Edition Notes 0x9 by DaNmarner * Compared to the traditional if control structure, unless works in the opposite way, which is equal to if (!condition) {} , else is conditional in this structure. * until structure function as while (!condition ) * if, unless, while, until, foreach can be used as expression modifiers. Thus, a statement can be written in reverse. The limitation for this is, only one expression is allowed on either side of the modifiers. * elsif equals to "else if" in if structure. * Autoincrement/decrement operator (++,--) is the same as them in C. * for loop, like in C, is available in perl, too. * last, as "break" in C, stops the loop's execution. Similarly, next ends the current iteration. * redo repeats current iteration in a loop. * last, next and redo can work with lables to effect the outer loop. The syntax is, say, when used in a while loop nested in a unless loop:
LABLENAME: unless { while { redo LABLENAME; } }
* The value of logical operator "&&" and "||" is the last evaluated part. And they could be written in words ("and", "or"). * The ternary operator (?:), as it in C, is availble in perl.

No comments: