From 03a60521d41962fb3d36e8e8002e9bba51796ff6 Mon Sep 17 00:00:00 2001 From: Francois Marier Date: Sun, 29 Jun 2008 21:51:31 +1200 Subject: Imported Upstream version v0.3.0 --- lib/CIL/Utils.pm | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'lib/CIL/Utils.pm') 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; ## ---------------------------------------------------------------------------- -- cgit v1.2.3