Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How do I extract this data structure?

by I0 (Priest)
on Dec 24, 2000 at 21:30 UTC ( [id://48203]=note: print w/replies, xml ) Need Help??


in reply to How do I extract this data structure?

$b0 = qr/[^{}]/; $b1 = qr/\{($b0*)\}/; $xy = qr/\{\s*(\d+)\D+(\d+)\s*\}/; $string=qr/\bstring\s*$b1/; $application=qr/\bapplication\s*\{($string|$b0)*\}*/; $id=qr/\s*\bid\s*"(.*?)"/; $origin=qr/\borigin\s*$xy/; $dimensions=qr/\bdimensions\s*$xy/; $parts=qr/$application|$id|$origin|$dimensions|$string|$b0/; $object=qr/\bobject\s*{$parts*}/; $sections = join'',<DATA>; while( $sections =~ m/($object)/g ){ local $_=$1; @object{m/$id/} = { origin=>[m/$origin/], dimensions=>[m/$dimensions/], } } print keys %object; __DATA__ object { origin { 0 0 } dimensions { 9360 130 } id "DAILY.evo" user-name "DAILY.evo" rc-name "DAILY.evo" application { app-name "ATEX-FPO-DUMMY-CONTROL" string { major-type "FRN" } string { ad-number "DAILY.evo" } } } object { origin { 0 130 } dimensions { 900 1 } id "1400.cm1" user-name "1400.cm1" rc-name "1400.cm1" application { app-name "ATEX-FPO-DUMMY-CONTROL" string { major-type "FRN" } string { ad-number "1400.cm1" } } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://48203]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-03-29 14:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found