One difference is that it do { ... }returns a value, while the if statement does not (although see the comments below).
eg:.
my $x = 3;
my $z = do { warn "in the do block"; 10 } if $x == 3;
You can do almost the same with the ternary operator, although you cannot order statements inside the branches of the ternary operator.
source
share