#! perl -slw use strict; use Data::Dumper; my $re = qr[ (string|float|float2|float3|float4) \s+ (\w+) \s* (?: < \s* ( [^>]+? ) \s* > \s* )? = \s* ( \S+ ) \s* ; ]x; my $data = do{ local $/; }; my %vars; while( $data =~ m[$re]smg ) { my( $type, $name, $structure, $value ) = ( $1, $2, $3, $4 ); $vars{ $name } = { type => $type, value => $value }; if( defined $structure ) { while( $structure =~ m[$re]smg ) { my( $stype, $sname, $svalue ) = ( $1, $2, $4 ); if( my( $prefix, $rest ) = $sname =~ m[([A-Z]+)([A-Z][a-z]+)] ) { $vars{ $name }{ $prefix }{ $rest } = $svalue; } } } } print Dumper \%vars; __DATA__ float myVarA < float UIMin = 1; float UIMax = 0; float UIStep = .001; string UIWidget = "slider"; > = 0.5f; float myVarB = 1.0; float4 myVarC = {1,0,0,1}; #### C:\test>junk2 $VAR1 = { 'myVarA' => { 'UI' => { 'Step' => '.001', 'Max' => '0', 'Widget' => '"slider"', 'Min' => '1' }, 'value' => '0.5f', 'type' => 'float' }, 'myVarC' => { 'value' => '{1,0,0,1}', 'type' => 'float4' }, 'myVarB' => { 'value' => '1.0', 'type' => 'float' } };