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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |