http://qs321.pair.com?node_id=373301

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

Hello Perl Monks,
I have been briefly been working with Perl and have mainly been using it to automate my daily tasks. Now, I'm writting a script that reads from a file, and analyses the first character of every line to format it.

For instance, if there is a line that reads "R Whatever", it becomes <li>Whatever</li>. That's all easy and has been written already.

The problem actually lies with another type of format. Example:
K Perl
K Monks
K Is
K Cool

Here, I need it to be outputted as:
<p>%Perl,%Monks,%Is,%Cool</p>

Since I'm reading every line individually I'm having a hard time formatting it this way, and especially knowing when to put the ending </p> tag.

Any help is greatly appreciated. Thanks for taking your time to read this :)

Marcos