summaryrefslogtreecommitdiff
path: root/lib/CIL/Utils.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CIL/Utils.pm')
-rw-r--r--lib/CIL/Utils.pm23
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/CIL/Utils.pm b/lib/CIL/Utils.pm
index a0e165c..e9611cf 100644
--- a/lib/CIL/Utils.pm
+++ b/lib/CIL/Utils.pm
@@ -26,6 +26,7 @@ use warnings;
use Carp;
use File::Slurp;
use File::Temp qw(tempfile);
+use Email::Find;
use POSIX qw(getpgrp tcgetpgrp);
use Fcntl qw(:DEFAULT :flock);
@@ -76,8 +77,9 @@ sub parse_from_lines {
}
}
- # now read everything that's left into the $last_field field
- $data->{$last_field} = join("\n", @lines);
+ # now read everything that's left into the $last_field field (if there is one)
+ $data->{$last_field} = join("\n", @lines)
+ if defined $last_field;
return $data;
}
@@ -128,6 +130,8 @@ sub write_cil_file {
sub solicit {
my ($class, $message) = @_;
+ $message = join('', @$message) if ref $message eq 'ARRAY';
+
# when calling this, assume we're already interactive
File::Temp->safe_level(File::Temp::HIGH);
@@ -179,6 +183,21 @@ sub ensure_interactive {
return;
}
+sub extract_email_address {
+ my ($class, $text) = @_;
+
+ my $email_address;
+ my $num_found = find_emails(
+ $text,
+ sub {
+ my ($mail_address, $text_email) = @_;
+ $email_address = $text_email;
+ }
+ );
+
+ return $email_address;
+}
+
## ----------------------------------------------------------------------------
1;
## ----------------------------------------------------------------------------