In Perl, you can follow any simple statement with a single optional modifier - So, you could write -

$foobar = $foobaz unless $foobaz < 0 ;

if and unless have the expected semantics, foreach will go through each value in EXPR, aliasing $_ to the value and executing the statement. The while and until modifiers have the usual 'while loop' semantics (the conditional is evaluated first) apart from when applied to a do block, in which case the block will execute once before the conditional is evaluated.

This is a pretty cool feature of perl, because it lets you write very "english"-sounding statements. To my mind at least,

statement if conditional;

looks nicer than:

if ( conditional ) { statement; }

Log in or register to write something here or to contact authors.