Let me see if I have this straight. You have a file, some sections of which are enclosed in hoinkies. There is only one level, meaning that nothing will be inside two sets of hoinkies. The file starts with a non-hoinky character. Also, there will be no other uses of brackets; for example:
if(x<10){string oops = ">";}
would not appear. Given these assumptions, you want to pull from this file the sections which are enclosed by the hoinkies. Is this accurate? Here is some code which I believe will solve this problem:
my @separated = split /<|>/, $snippet;
This way, every even entry in the array (starting with the 0th) will have non-UI-related text in it and every odd entry will have UI-text in it. Maybe not enlightened, but it works for me ;)
If the problem is more complex than this, regexen may not be the greatest solution... parsing code is tough and some module may be able to help.

Update: After working on this for a while... parsing code is so hard! What if a value contains <, or >, "semi;", /float(.*)=\;/, etc.? I don't have a module to suggest, but this seems analogous to html parsing-- doing it with regexen will be full of difficulties and exceptions, doing it with a module would be preferable. If you can change the format of the UI data it might also make your job easier. Good luck!
~dewey

In reply to Re: Tricky Parsing Ko'an by dewey
in thread Tricky Parsing Ko'an by jmmistrot

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.