Hello Monks, i've got a bit of a problem here that i need your advice on how to go about it.

I have to create a script, that when operated on specific text files, will be able to read diagrams like those below. It should determine which are left connectors and which are right connectors and associate abbreviated names to the respective connectors, e.g. L1, L2, R2, R5, obviously depending on which side the connector is and how many there are.

[ ABC12 ]----------38.00M----------[ DEF23 ] |---16M------[ DEF23 ] [ ABC12 ]---------- |---16M------[ DEF34 ] [ ABC12 ]-------- | [ ABC23 ]--------|---42m---[ DEF23 ] | [ ABC34 ]--------

The structure is as it appears...bracket, tab, connector id, space, bracket, dashes, length, dashes, bracket, space, connector id, tab, bracket.

It should be able to recognise any number of connectors on each side (1 on left 6 on right, 2 on left 4 on right etc).
Note that there is only one diagram in each text file that is read in.
The length/name of the connector ids, number of dashes denoting the cable & the cable length isn't consistent in any way. The only thing that is consistent is the brackets surrounding the connector ids.

Im having trouble making a program recognise which is on the left and which is on the right. If it were 1 to 1, 1 to 3 etc it would be easy as i would assume for each line, the first '[' it sees belongs to a left connector and the second '[' to a right connector, but you have some lines that only have the right connector on.

Any help/pointers/advice etc anyone can offer is very appreciated. Cheers, Steve

Edit by tye, escape [


In reply to electronic diagram recognisation by Anonymous Monk

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.