Line 245:
Line 245:
}
}
−
There's also a negated version of it:
+
There's also a negated version of it:
unless ( condition ) {
unless ( condition ) {
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:
# the traditional way
# the traditional way
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 281:
Line 281:
==== for ====
==== for ====
−
Exactly like C:
+
Exactly like C:
for ($i = 0; $i <= $max; $i++) {
for ($i = 0; $i <= $max; $i++) {