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

Monks Please Help....I have a standard email parsing program which stores each line of the body of an email as an element in an array. I am parsing through these elements to extract data and save it in a database. Here is the problem the only way I could get the script to work is in the following format. This format works for most cases, but once I have found the string I am searching for I want to skip ahead one or two elements in the array. I realize this is probably a simple problem, I greatly appreciate all the help you are willing to give.
$msg = Mail::Internet->new([ <> ]); $from = $msg->get('From'); $msg->combine('To'); $to = $msg->get('To'); $subject = $msg->get('Subject'); $body = $msg->body(); foreach (@$body){ if (($_ =~ $x) or ($_ =~ $y)){ chop $_; $array[9][1] = $_; } }
Typically to advance the array an element or two I would use:
$i++; $array[9][1] = $body[$i];
But this doesn't seem to work.

Replies are listed 'Best First'.
Re: email parsing
by mfriedman (Monk) on Jun 04, 2002 at 16:05 UTC
    It looks like you're using an array reference. If so, you'll need to dereference it properly:

    $body->[$i];