You don't say how you want to use the information parsed, so it difficult to know how best to structure it. Parallel arrays is almost certainly not the best way, but it was simple for a test.
I've scrunched all the data into a single 'file', and used 'paragraph mode' for simplicity.
#! perl -slw use strict; $/=''; while( my @lines = split "\n", <DATA> ) { my( @left, @right, @Ldist, @Rdist ); ## The only way I know to ensure $1 & $2 are cleared! for( @lines ) { 'a' =~ m[.]; push @left, $1 if m[ \x5b \s+ ( [A-Z0-9]+ ) \s+ \x5d -+ ( [\d\.]+ . )? ]x; $Ldist[ $#left ] = $2||'-' if $1; ## The only way I know to ensure $1 & $2 are cleared! 'a' =~ m[.]; push @right, $2 if m[ - ( [\d\.]+ . )? -+ \x5b \s+ ( [A-Z0-9]+ ) \s+ \x5d ]x; $Rdist[ $#right ] = $1||'-' if $2; } print "@left (@Ldist) connect to @right (@Rdist)"; } __DATA__ [ ABC12 ]----------38.00M----------[ DEF23 ] |---16M------[ DEF23 ] [ ABC12 ]---------- |---16M------[ DEF34 ] [ ABC12 ]-------- | [ ABC23 ]--------|---42m---[ DEF23 ] | [ ABC34 ]--------
Output
P:\test>junk2 ABC12 (38.00M) connect to DEF23 (38.00M) ABC12 (-) connect to DEF23 DEF34 (16M 16M) ABC12 ABC23 ABC34 (- - -) connect to DEF23 (42m)
In reply to Re: electronic diagram recognisation
by BrowserUk
in thread electronic diagram recognisation
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |