So I took your advice and made the following changes:

my %wanted; my %validfile = map +($_ => 1), qw/ dir file link /; my %validupdate = map +($_ => 1), qw/ mode owner group /; for (keys %{ $config{$test}{$tester} }) { my($filetype, $updatetype) = split /-/, $_, 2; unless ($validfile{$filetype} && $validupdate{$updatet +ype}) { warn "Unexpected directive '$_'"; next; } $wanted{$filetype}{$updatetype} = $config{$test}{$test +er}{$_}; } [...] sub wanted_c { print "wanted_c is working on $_\n"; my %wanted_prev = %wanted; my $wanted_here; stat($_); if (-d $_) {$wanted_here = $wanted_prev{'dir'}} elsif (-l $_) {$wanted_here = $wanted_prev{'link'}} elsif (-f $_) {$wanted_here = $wanted_prev{'file'}} else {return;} return unless $wanted_here; # nothing to change print Dumper($wanted_here); if (defined $wanted_here->{'mode'}) { change_mode($_, $wanted_here->{'mode'}) + } if (defined $wanted_here->{'owner'}) { change_owner($_, $wanted_here->{'owner'}); } if (defined $wanted_here->{'group'}) { change_group($_, $wanted_here->{'group'}); } }

The changes work like a charm. I have one problem and one question though. The problem is that I keep getting a diagnostic warning:

Variable "%wanted" will not stay shared at permmy7.pl line 317 (#1)

I am a little unsure about how best to go about getting rid of it. Can't _really_ see an easy way to sub something out...

The question I have is, previously I was having issues with the file/directory/link being checked by the wanted_c function hitting only one if and then returning, so I had to toss in some recurssion - why doesn't that problem occur with the above code? I am just not seeing it and it is bugging me. It works and I am thankful for that but I want to know _why_ it works... Thanks in advance.

-Shane


In reply to Re: Re: Re: Re: Permissions Utility Script for sysadmins - seeking comments by BuddhaNature
in thread Permissions Utility Script for sysadmins - seeking comments by BuddhaNature

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.