in reply to Confused: Hashrefs in TieRegistry
What are you trying to do with:
Dumper %RegHash = $error;
It looks like you are assigning a scalar to a hash to me and that is not going to work.
If I edit your while loop and environs a little to give:
# Dumper %RegHash = $error; # while (@set = 2) { @set = each %RegHash or die "failure to read registry: + $! \nlast contents of Registry Hash = $error \n"; last if @set != 2; if ($set[0] eq "/"){ print "$val = $set[0]\n"; $watchcode = 1; } next; # added }
then I get output tht looks like:
.3/ = / .386/ = / .A51/ = / .ac3/ = / .aca/ = / .ace/ = / .acf/ = / ...
Update: The following is probably closer to what you actually want:
#!/usr/bin/perl use warnings; use strict; use Win32::TieRegistry (Delimiter => "/"); exit if defined($ARGV[0]); # Why btw? foreach my $class (sort keys %{ $Registry->{"Classes/"} }){ next unless $class =~ /^[.]/; my %RegHash = %{ $Registry->{"Classes/$class"} }; print "$class = $RegHash{'/'}\n" if exists $RegHash{'/'}; }
Prints:
.3/ = 3_auto_file .323/ = h323file .386/ = vxdfile .3g2/ = QuickTime.3g2 .3gp/ = QuickTime.3gp .3gp2/ = QuickTime.3gp2 ...
Update: Doh! replaced inner loop per ikegami
Note that missing associations is not an error so no warning or dies. The if exists modifier could be changed to a full blown if and note the missing association in the else part.
|
|---|