note
shmem
First off, what did <i>you</i> try so far? Please read [id://243874].
<p>
Then, what you are referring to as paragraphs in your example are lines. This may seem picky,
but the distinction between lines and paragraphs makes sense. There is a <i>paragraph mode</i>
reading files. See [doc://perlrun], there the switch -0 and the special value 00 for it.
<code>
blah blah blah #line \
blah blah blah #line - paragraph
blah blah blah #line /
<--- paragraph separator
blah blah blah #line \
blah blah blah #line - paragraph
blah blah blah #line /
</code>
<p>
I would do this:
<code>
#!/usr/bin/perl
$file = shift;
open(I,"<$file");
local $/;
$_ = <I>;
s|<list>(.*?)</list>|"<list>".join("\n",map{"<item>$_</item>"}
split"\n",$1)."</list>"|ges;
print;
</code>
Note that the "\n" for <i>join</i> and <i>split</i> should be "\r\n" for Windows and "\r" for Mac systems.<br/>
<p>You can stuff that into a one-liner:
<code>
perl -p00 -e 's|<list>(.*?)</list>|"<list>".join("\n",map{"<item>$_</item>"}split"\n",$1)."</list>"|ges;' textfile
</code>
Now go and read [doc://perlre] and [doc://perlvar].
<p>
greets,<br/>
--shmem
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-510280">
<small><pre>_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}</pre></small>
</div></div>
556880
556880