#!/usr/bin/perl use warnings; use strict; use Win32::TieRegistry (Delimiter => "/"); use Data::Dumper; my $val; my $val2; my @set = (1,2); my $watchcode = 0; my $error; unless (defined($ARGV[0])){ foreach $val (keys %{ $Registry->{"Classes/"} }){ if ($val =~ /^[.]/) { my %RegHash = %{ $Registry->{"Classes/$val"} }; Dumper %RegHash = $error; while (@set = 2){ @set = each %RegHash or die "failure to read registry +: $! \nlast contents of Registry Hash = $error \n"; if ($set[1] eq "/"){ print "$val = $set[0]\n"; $watchcode = 1; } } if ($watchcode == 0){ die "failure to recognise association list: $!"; } } } };
it's supposed to be part of a direct lookalike of the plain 'assoc' utility in Windows 2000/XP which, when invoked on it's own, lists the extensions and the associated filetypes on the system.
what actually happens when I exectute is this:
which suggests that the $registry reference isn't behaving as I expect it too when it's fed to the 'each' function, however this is strange, because it works fine with 'keys' and 'values'... except when i try to get it too read the default value under the key "/".Odd number of elements in hash assignment at E:\workspaces\perl\asoc.p +l line 17. Use of uninitialized value in list assignment at E:\workspaces\perl\as +oc.pl line 17. Use of uninitialized value in string eq at E:\workspaces\perl\asoc.pl +line 20. Use of uninitialized value in concatenation (.) or string at E:\worksp +aces\perl\ asoc.pl line 19. failure to read registry: last contents of Registry Hash =
*sigh* i'm beginning to understand where perl gets it's name from, I must seriously be missing something about references or objects or TiedHashes excetera
I also think i might be missing something about how the TieRegistry module does work (or doesn't as the case may be)In reply to Confused: Hashrefs in TieRegistry by Maze
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |