Hi all, my perl is weak, I wrote a script to return a list of file extensions if a couple of values are present in windows registry. It works, but I'm hoping y'all can give me some tips on improving my code.
#!/usr/bin/perl # FileExtP.pl will generate a list of files with incorrect settings f +or "confirm open after download" # and "always show extension" # Use to determine if these values are set in registry. # File extensions will be loaded from a user supplied file. # 1/18/2009 use strict; use warnings; my $Registry; use Win32::TieRegistry( TiedRef => \$Registry, Delimiter=>"/", SplitMultis => 1, ArrayValues=>1, qw( REG_SZ REG_EXPAND_SZ REG_DWORD REG_BINARY +REG_MULTI_SZ KEY_READ ), ); open (my $FI, "fileExtensionList.txt") || die "couldn't open input fil +e"; open (my $FO, "> fileOut.txt") || die "couldn't open output file"; $Registry->Delimiter("/"); # Set delimiter to "/". my $regKey = $Registry->{"Classes/"}; my (@fileExtArr); while (<$FI>) { # get the extensions s/#.*//; # ignore comments next if /^(\s)*$/; # skip blank lines my($Temp)=$_; #Store each line from $FileName to $Temp chomp ($Temp); #strip eol character push @fileExtArr, $Temp; } #testing, only, get all file extensions from HKCR #my @allClassKeys = keys( %{$regKey} ); #@fileExtArr = grep {/^\..*/} @allClassKeys; # foreach(@fileExtArr){ # print "$_\n"; # } my $ctr = 0; foreach(@fileExtArr){ # get value of key each extension points to my $eachSubKey = $regKey->{"$_"} or warn " $_ $^E\n"; if($eachSubKey){ my $keyPtr = $eachSubKey->GetValue("") or warn "$_ $^E\n"; +# go to this key for value if($keyPtr){ # check this key for these values if(!$regKey->{$keyPtr}->{"AlwaysShowExt"} || !$regKey->{ +$keyPtr}->{"EditFlags"}){ $ctr++; print "$ctr $_ $keyPtr\n"; } } } } close($FI); close($FO); exit 0;

In reply to tieregistry file ext search script critique by gebuh

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.