Capacio, Paula J wrote: > The documentation states that the InstalledPackageProperties function, > returns a hash with package names as keys, and package properties as > attributes. What I got back however leads me to believe that it returns > the package names as keys but the package properties as a reference to a > hash. I tried de-referencing the hash but am still not getting what I > expected. I'm expecting to get a list of the installed modules followed > by each property and it's value, something similar to > module name > author= somebody > version= x.0x > etc > I guess I just don't understand references after all, can anybody spot > what I'm doing wrong? > TIA > Paula > **also sorry in advance if this is every other line, I see that happens > on some of my posts and I don't know why. > > ##code > use PPM; > print "PPM Installed Module Properties....\n"; > %insModProps = PPM::InstalledPackageProperties(); > foreach $insMod (sort keys %insModProps) { > print "\t$insMod=$insModProps{$insMod}\n"; > $modProps = $insModProps{$insMod}; > foreach $prop (sort keys %$modProps) { > print "\t\t$prop=$modProps{$prop}\n"; > } > } > ##end of code
Try: use strict; use PPM; print "PPM Installed Module Properties\n\n"; my %insModProps = PPM::InstalledPackageProperties(); foreach (sort keys %insModProps) { if (ref ($insModProps{$_}) !~ /hash/i) { print "\t$_ = $insModProps{$_}\n"; next; } print "$_:\n"; my $modProps = $insModProps{$_}; foreach (sort keys %$modProps) { my $line = $modProps->{$_}; if (defined $line) { chomp $line; if (ref ($line) =~ /ARRAY/i) { printf "\t$_:\n"; foreach (@$line) { chomp; printf "\t\t$_\n"; } } else { # clean it up a bit $line =~ s/\r?\n\r?/ /gs; $line =~ s/\n\>/>\n/s; $line =~ s/\s+/ /g; $line = sprintf "$_ = %s", $line; $line =~ s/(.{1,71}($|\s))/\t\t$1\n/g; $line =~ s/^\s+//; $line =~ s/\s+$//; printf "\t%s\n", $line; } } else { print "\t$_ = undef\n"; } } } __END__ -- ,-/- __ _ _ $Bill Luebkert ICQ=14439852 (_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /--< o // // http://dbecoll.tripod.com/ (Free site for Perl) -/-' /___/_<_</_</_ Castle of Medieval Myth & Magic http://www.todbe.com/ _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users