Next | Trivial Utilities | 140 |
Most of the rest is just assembling an email message
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 .= $_; } }
The -t STDIN thing may be handy in other commands
It asks if STDIN is attached to a terminal device
Next | Menu | Copyright © 2012 M. J. Dominus |