shammi000 has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

How can i handle a bunch of lines as a ID or File Handle (without saving it in a temp file).

I am getting the mail contents from a db, and i need to process the entire content in my script. Some times mail contains 50K lines or more. (Including attachments).

Regards,
Shameem

Replies are listed 'Best First'.
Re: Handle bunch of lines as a Handle
by ikegami (Patriarch) on Mar 03, 2010 at 08:01 UTC
    Are you asking for something like
    open(my $fh, '<', \$var);

    That will allow you to read the contents of $var via file handle $fh.

    By the way, please don't place your code in PRE tags. Use <p> at the start of paragraphs, and wrap computer text (programs, data, output, etc) in <c>...</c> tags.)

Re: Handle bunch of lines as a Handle
by Tux (Canon) on Mar 03, 2010 at 08:04 UTC
    open my $fh, "<", \$e_mail or die; while (<$fh>) { # process line }

    Enjoy, Have FUN! H.Merijn
Re: Handle bunch of lines as a Handle
by ungalnanban (Pilgrim) on Mar 03, 2010 at 08:11 UTC


    Using IO::String module we can handle a bunch of line as a file handle.

    --sugumar--