Sometimes based on some condition a piece of code has to be executed or not.

examples/scalars/if_conditional.pl
#!/usr/bin/perl
use strict;
use warnings;

print "First number: ";
my $x = <STDIN>;
chomp $x;

print "Second number: ";
my $y = <STDIN>;
chomp $y;

if ($y == 0) {
    print "Cannot divide by zero\n";
} else {
    my $z = $x / $y;
    print "The result is $z\n";
}