#!/usr/bin/perl #File: divide.pl #Author: Jessen Bredeson use strict; use warnings; my $x = shift; my $y = shift; if (! defined($x) or ! defined($y)) { print(STDERR "Please provide two numbers.\n"); } elsif ($x < 0 or $y < 0) { print(STDERR "Numbers must be positive.\n"); } elsif ($y == 0) { print(STDERR "Illegal division by zero.\n"); } else { printf(STDOUT "%0.2f\n", $x / $y); } # The proper way to redirect the various outputs of this script on the command-line: # divide.pl 2 3 >out.txt 2>err.txt