#!/usr/bin/perl

print STDOUT "Multiply number with *3\n";
print STDOUT "Enter a number : ";
chomp ( $input = <STDIN> );

if ( $input =~ /\D/ ) {
   print STDERR "Not a number !!!!\n";
} else {
   print STDOUT 'The answer is ', $input * 3, "\n";
   print STDOUT "The result is also save on the external file 'res.txt'\n";
   open $OUT, '>', 'res.txt' or die "Cannot open file 'res.txt'\n";
   print $OUT 'The answer is ', $input * 3, "\n";
   close $OUT;
}
