in reply to question on multi line pattern matching for html formatting
...the text I am concerned with is in an array (@ThisFileArray)...A for loop is usually better for looping over an array.
...with paragraphs separated by an extra newline....Perl can do that for you if you set $/ (see How can I read in a file by paragraphs?).
#!/usr/bin/perl use strict; use warnings; { local $/ = q{}; my @txt = <DATA>; for (@txt) { chomp; print qq{*$_*\n}; } } __DATA__ Text blah blah, make my point here. More text and even more continuing + on along the way. New paragraph starts here, there were 2 newlines just before I started + this paragraph, so I should somehow be able to match on that, but I can't figure out how to search for that throug +h my array.
Note that the extra pair of braces and local restricts the scope of the change to $/ (which is a global).*Text blah blah, make my point here. More text and even more continuin +g on along the way.* *New paragraph starts here, there were 2 newlines just before I starte +d this paragraph, so I should somehow be able to match on that, but I can't figure out how to search for that throug +h my array.*
I've added stars instead of tags. I would seriously consider using something like HTML::Element's new method to deal with creating HTML tags. YMMV.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: question on multi line pattern matching for html formatting
by tallCoolOne (Initiate) on May 19, 2009 at 00:30 UTC | |
by wfsp (Abbot) on May 19, 2009 at 06:40 UTC | |
by tallCoolOne (Initiate) on May 19, 2009 at 18:02 UTC | |
by wfsp (Abbot) on May 19, 2009 at 19:09 UTC | |
by tallCoolOne (Initiate) on May 20, 2009 at 06:14 UTC | |
by tallCoolOne (Initiate) on May 19, 2009 at 01:09 UTC | |
by tallCoolOne (Initiate) on May 19, 2009 at 05:47 UTC |