my @COLORS = qw( white red blue green yellow );
return exists $COLORS[$i] ? $COLORS[$i] : $COLORS[0];
####
return $i < 5 ? 'red'
: $i < 20 ? 'blue'
: $i%3 == 0 ? 'green'
: $i%5 == 0 ? 'yellow'
: 'white';
####
print "This is my very long string that I wish to print out to display my message on the screen but only when I want it too!"
if $i == 1;
# the very common 'or die' idiom with a big brutish open()
open (
my $filehandlewithalongname,
$modevariablewithalongname,
$pathvariablewithalongname
) or die "Unable to open file $pathvariablewithalongname: $!\n";
# 'or die' again with a smaller, kinder open:
open ( my $fh, $mode, $path )
or die "Unable to open $path: $!\n";
# is equivalent to this 'die unless'
# which I have never seen used with open().
die "Unable to open $path: $!\n"
unless open ( my $fh, $mode, $path )
# however, 'die unless' is common with value checks.
die "Illegal value: $rotifer\n"
unless $rotifer =~ /^is ok$/;
# as is 'die if'
die "Illegal value: $rotifer\n"
if $rotifer =~ /^is not ok$/;