#!/usr/local/bin/perl # Jaime Prilusky, 2003 # Traditional form my $description; foreach my $i ( 1 .. 10) { my $num = rand(10) - 5; if ($num > 0) { $description = "positive"; } else { $description = "negative"; } print "$num is $description\n"; } # Compact form foreach my $i ( 1 .. 10) { my $num = rand(10) - 5; my $description = ($num > 0) ? "positive" : "negative"; print "$num is $description\n"; }