簡単なプログラムがあります
use strict;
use warnings;
print "Enter a number:\n";
my $number1 = <STDIN>;
chomp $number1;
print "Enter another number:\n";
my $number2 = <STDIN>;
chomp $number2;
if ( $number2 == 0 ) {
print "error: cnt divide by zero\n";
}
elsif ( ( $number1 == 0 ) or ( $number2 == 1 )) {
print "$number1\n";
}
else {
my $div = $number1 / $number2;
print "the result is: $div\n";
}
しかし、なぜ印刷するのかわかりません(STDINの後に数字を入力して別の数字を入力すると表示されます)。次の出力が得られます
[612] perl test.pl
2
0
Enter a number:
Enter another number:
error:cnt divide by zero