| Next | Trivial Utilities | 144 |
Then the usual option handling:
$from = $opt_f || default_from();
sub default_from {
my $user = $ENV{USER} || getpwuid($<);
my $host = $ENV{HOSTNAME};
$host ? join '@', $user, $host : $user;
}
if ($opt_o && $opt_O) {
print STDERR "-O and -o are incompatible.\n";
exit 1;
}
if ($opt_O) { $opt_o = "| $MAILER" }
Later we will open $opt_o as a file
Perl's magic open is very helpful here
unless (defined $opt_o) {
if (defined $ENV{DRAFT}) {
$opt_o = $ENV{DRAFT};
$DRAFT = 1;
} else {
$opt_o = '-';
}
}
$DRAFT is apparently unused; I don't know what I was thinking there
if ($opt_o !~ /^[|>]/) {
$opt_o = "> $opt_o";
}
open OUTPUT, "$opt_o"
or die "Couldn't open output file $opt_o: $!; aborting";
| Next | Menu | ![]() |
Copyright © 2012 M. J. Dominus |