HKEY_LOCAL_MACHINE\SOFTWARE\VENDOR\PRODUCT\CurrentVersion\Reports\NamespaceProviders=25137 ODBC:= reportsodbclog; REG_SZ SQLBulkInsertFlushInterval= 0x3c; REG_DWORD SQLBulkInsertFlushRowCount= 0x3e8; REG_DWORD SYSLOG:= reportssyslog; REG_SZ TEXT:= reportstextlog; REG_SZ HKEY_LOCAL_MACHINE\SOFTWARE\VENDOR\PRODUCT\CurrentVersion\SessionServer=12060 MaintenancePeriod= 0x3c; REG_DWORD MaintenanceQueryTimeout= 0x3c; REG_DWORD HKEY_LOCAL_MACHINE\SOFTWARE\VENDOR\PRODUCT\CurrentVersion\SessionServer\NamespaceProviders=32225 LDAP:= ssprovider_ldap; REG_SZ ODBC:= ssprovider_db; REG_SZ #### #Currently I am creating a key named 'DEF_VAL' and assigning the parent key's value to that. Any suggestions? use warnings; use strict; use Data::Dumper; print Dumper loadreg('file.reg'); sub loadreg{ my $registry; open(REGISTRY,'<',shift) or die("Error loading registry: $!\n"); my @reg = ; close REGISTRY; my $head = 0; my $section = ""; for my $line ( @reg ) { #if ( $line =~ /^\s?(HKEY.*)\n/ ) { if ( $line =~ /^\s?HKEY.*?CurrentVersion\\(.*)\n/ ) { # found start of section $head = 1; my ( $key , $def_val ) = split /=/ , $1; $key =~ s/\\/\//g; $registry->{$key}{"DEF_VAL"} = $def_val; $section = $key; } elsif ( $head == 1 and $line =~ /^\n$/ ) { $head = 0; $section = ""; } elsif ( $head == 1 and $line =~ /^[a-z]/i ) { # this is a key/value line for the current section # MaxReferralHops= 0xa; REG_DWORD # LDAP:= dsldap; REG_SZ $line =~ /^([^=:]+)[:=]+\s+([^;]+);\s+([^ ]+)\n$/; my $value = $2; $value = hex($value) if $value =~ /^0x/; $registry->{$section}{$1}{"VALUE"} = $value if $1; $registry->{$section}{$1}{"TYPE"} = $3 if $1; } } return($registry); } #### $VAR1 = { 'SessionServer/NamespaceProviders' => { 'ODBC' => { 'VALUE' => 'ssprovider_db', 'TYPE' => 'REG_SZ' }, 'LDAP' => { 'VALUE' => 'ssprovider_ldap', 'TYPE' => 'REG_SZ' }, 'DEF_VAL' => '32225' }, 'SessionServer' => { 'DEF_VAL' => '12060' }, 'Reports/NamespaceProviders' => { 'TEXT' => { 'VALUE' => 'reportstextlog', 'TYPE' => 'REG_SZ' }, 'ODBC' => { 'VALUE' => 'reportsodbclog', 'TYPE' => 'REG_SZ' }, 'SYSLOG' => { 'VALUE' => 'reportssyslog', 'TYPE' => 'REG_SZ' }, 'DEF_VAL' => '25137' } };