App-MonM
view release on metacpan or search on metacpan
lib/App/MonM/Message.pm view on Meta::CPAN
329330331332333334335336337338339340341342343344345346347348349
$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
->
(
->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
359360361362363364365366367368369370371372373374375376377378379
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::MIME->new(
$buf
);
$self
->email(
);
my
$to
=
->header(
"To"
);
# Add X-Recipient
lib/App/MonM/Util.pm view on Meta::CPAN
353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
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
->
(
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 )