App-MonM

 view release on metacpan or  search on metacpan

lib/App/MonM/Message.pm  view on Meta::CPAN

        $self->error("No email object found");
        return;
    }

    my $fh = IO::File->new($file, "w");
    unless (defined $fh) {
        $self->error("Can't write file $file: $!");
        return;
    }

    $fh->binmode(); # ':raw:utf8'
    $fh->print($email->as_string);
    undef $fh;
    return 1;
}
sub load {
    my $self = shift;
    my $file = shift;
    $self->error("");
    unless ($file) {
        $self->error("No file specified");

lib/App/MonM/Message.pm  view on Meta::CPAN

        return;
    }

    # Load file
    my $fh = IO::File->new($file, "r");
    unless (defined $fh) {
        $self->error("Can't load file $file: $!");
        return;
    }

    $fh->binmode(':raw:utf8');
    my $buf;
    read $fh, $buf, $size; # File::Slurp in a nutshell
    undef $fh;

    # Set email object
    my $email = Email::MIME->new($buf);
    $self->email($email);
    my $to = $email->header("To");

    # Add X-Recipient

lib/App/MonM/Util.pm  view on Meta::CPAN

    my $s = shift // "";
    $s =~ s/\b(\w)/\u$1/g;
    return $s;
}
sub slurp {
    my $file = shift;
    my $isbin = shift || 0;
    return "" unless $file;
    my $fh = IO::File->new($file, "r");
    return unless defined $fh; # "Can't load file $file: $!"
    $isbin ? $fh->binmode : $fh->binmode(':raw:utf8');

    my $ret;
    my $content = "";
    my $buf;
    while ($ret = read($fh, $buf, 131072)) {
        $content .= $buf;
    }
    undef $fh;
    return unless defined $ret;
    return $content;
}
sub spurt {
    my $file = shift;
    my @arr = @_;
    my $fh = IO::File->new($file, "w");
    return "Can't write file $file: $!" unless defined $fh;
    $fh->binmode(':raw:utf8');
    $fh->print(join("\n", @arr));
    undef $fh;
    return "";
}
sub spew {goto &spurt}
sub run_cmd {
    my $cmd = shift;
    my $timeout = shift || 0;
    my $exe_in = shift;



( run in 0.385 second using v1.01-cache-2.11-cpan-bf8d7bb2d05 )