in reply to Unix system commands to Perl
use strict; use warnings; use Mail::Mailer; # mfile == 'Mail File' in context my $mfile = "somefile.txt"; # Override the default mailer found when the module was # installed (looks for 'mail', 'Mail' by default) my $mailer = Mail::Mailer->new("mail", "/usr/bin/mailx"); $mailer->open('From' =>'Joe User <juser@domain.com>', 'To' =>'Sally Seashells <ss@sshore.com>', 'Subject'=>'Do you sell seashells by the seashore?'); open (MFILE, "<$mfile") or die "Cannot open file: $!"; print $mailer MFILE; close MFILE; close($mailer) or die "Cannot close mailer: $!";
For your second task, you could always use something like this:
package Stderr; sub new { bless {} } # Turn off stderr sub stderr_off { open(SAVEERR, ">&STDERR"); close(STDERR); } # Turn on stderr sub stderr_on { open(STDERR, ">&SAVEERR"); close(SAVEERR); } 1;
|
|---|