Next Trivial Utilities 140

forge

        if ($m_file eq '-') {
          local $/;
          die "No subject specified; aborting" unless defined $opt_s;
          $message = <STDIN>;
        } elsif ($m_file) {
          local $/;
          die "No subject specified; aborting" unless defined $opt_s;
          open M, "< $m_file" 
            or die "Couldn't open file $m_file for reading: $!;
            aborting";
          $message = <M>;
          close M;
        } else {
          unless (-t STDIN) {
            die "standard input not a terminal; 
                   use -m and -s options; aborting";
          }
          unless (defined $opt_s) {
            print STDERR "Subject: ";
            chomp($subj = <STDIN>);
          }
          print STDERR "Enter message on standard input; 
                          use . to terminate.\n";
          while (<STDIN>) {
            last if $_ eq ".\n";
            $message .= $_;
          }
        }


Next Menu Copyright © 2012 M. J. Dominus