diff options
author | Francois Marier <francois@debian.org> | 2008-06-29 21:51:31 +1200 |
---|---|---|
committer | Francois Marier <francois@debian.org> | 2008-06-29 21:51:31 +1200 |
commit | 03a60521d41962fb3d36e8e8002e9bba51796ff6 (patch) | |
tree | 36150e8a410695002674e5ad202c425d1796b0c9 /lib/CIL/Utils.pm | |
parent | 42280f662d3ce4affb00eb68a22a081dfb951395 (diff) |
Imported Upstream version v0.3.0upstream/v0.3.0
Diffstat (limited to 'lib/CIL/Utils.pm')
-rw-r--r-- | lib/CIL/Utils.pm | 23 |
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; ## ---------------------------------------------------------------------------- |