#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); }