programming-examples/perl/Statement/Conditional Control Statements.pl

24 lines
540 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
# if (Expression) {Code Segment}
# if (Expression) {Code Segment} else {Code Segment}
# if (Expression) {Code Segment} elsif {Code Segment} ... else {Code Segment}
#!/usr/local/bin/perl -w
while (<STDIN>)
{
chomp;
if ($_ < 10)
{
print "$_ is less than 10.\n";
}
elsif ($_ < 20)
{
print "$_ is between the values of 10 and 19.\n";
}
else
{
print "$_ is greater than or equal to 20.\n";
}
}