Email::Find has, I think, a curious design. The text returned by the callback function is used to modify the contents of the original input text passed to the "find()" method, and "find()" itself simply returns "true" or "false" (1 or 0) for success or failure.

The easiest way to get what you want (but perhaps not satisfactory in terms of OO/modular design) would be to use an array that is "global" to the main caller and callback function:

#!/usr/bin/perl use strict; use warnings; use Email::Find; my $text = "this is some text test\@email.com foo bar"; my @found; my $finder = Email::Find->new( \&find_email ); $finder->find(\$text); print "Found says @found\n"; exit; sub find_email { my ( $email, $orig_email ) = @_; my $ret = $email->format(); print "sub says " ,$ret, "\n"; push @found, $ret; return; } # end-sub
(Note that by returning undef, the callback will be removing email addresses from the original text string as they are processed.)

In reply to Re: Email::Find question by graff
in thread Email::Find question by rsiedl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.