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.


DWIM is Perl's answer to Gödel

In reply to Re: Confused: Hashrefs in TieRegistry by GrandFather
in thread Confused: Hashrefs in TieRegistry by Maze

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.