Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'm using the # as the separater and so far I can successfully split the one email into my usable pieces. my @split_msg = split(/#############################################/, $message); That part is good. Now I'm having more problems breaking each thing down to TITLE, TAG and MESSAGE.[title] blah blah blah [title] [tags] tag tag blah blah [tags] [message] blah blah blah red riding hood runs away from the scary wolf blah blah [message] ############################################# [title] another one [title] [tags] more tags [tags] [message] another message here [message] ############################################# [title] last one [title] [tags] last one [tags] [message] more fun here [message]
The above code keeps saying MSG is uninitialized. It was originall (.+) but I tried (.*) to see if that would make any difference. Each portion (tag, title, message) can contain new lines and I have to capture whatever is in between each of them.foreach my $email (@split_msg) { my ($title, $tags, $msg); $email =~ m/\[title\](.+)\[title\]/i; $title = $1; $email =~ m/\[message\](.*)\[message\]/i; $msg = $2; print "$title\n\n$msg\n\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: regex problem
by raybies (Chaplain) on Mar 17, 2011 at 15:10 UTC | |
Re: regex problem
by arkturuz (Curate) on Mar 17, 2011 at 15:15 UTC | |
by jaimon (Sexton) on Mar 18, 2011 at 14:08 UTC | |
by arkturuz (Curate) on Mar 22, 2011 at 12:53 UTC | |
Re: regex problem
by Anonymous Monk on Mar 17, 2011 at 15:11 UTC |