App-MonM

 view release on metacpan or  search on metacpan

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

329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
        $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

359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
    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

353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
    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.224 second using v1.01-cache-2.11-cpan-bf8d7bb2d05 )