Next Trivial Utilities 144

attach

        $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" }

        unless (defined $opt_o) {
          if (defined $ENV{DRAFT}) {
            $opt_o = $ENV{DRAFT};
            $DRAFT = 1;
          } else {
            $opt_o = '-';
          }
        }
        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