So the first thing you want to do is learn about regexp (regular expressions). It's kind a wierd concept, but once you learn how to look at your source file, it grows easier and easier.
Now, your data is a variable. I'm assuming you'll eventually want to read this from a file? Correct? I have a recommendation. If you're going to read the data from a file, I highly recommend you set your script up to do that already. It may affect the behavior of your regexp in the long run. Best to get the environment into place and code around it rather than to force the environment to fit your code.
Anyhow, regexps work by finding and or find/replace methods. You'll search for the elements that you want. Actually, in this case, you'll be searching for the things that break up the elements you want. I could be wrong, but it looks to me that your list is separated by line breaks and space breaks. So you'll want to read all the data from your variable, and search through it looking for spaces and line breaks. You'll of course want to replace each with the appropriate html code. Don't forget to start each line with a new line and cell.
Since you're new to perl, I'd figure out how to replace these spaces and elements one at a time. You'll want to iterate through your big variable stream more than once. This is not common practice for later down the road, as it is a bit slow, but it'll help you to understand what is/isn't working if something breaks. Then figure out how to optimize it by combining all the search/replaces at once.
--Coplan
In reply to Re: Parsing Variables
by Coplan
in thread Parsing Variables
by JoeJaz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |