Bother, I was right the first time, and looking at the wrong bit of code the second time.

The wanted_c routine is called once for each file, and in the original code it goes through a series of elsifs until it finds a match, so it will only act on the first match - the first combination of filetype and updatetype that is appropriate.

So to fix it you need to avoid that; the minimal fix would probably be something like this:

sub wanted_c { if (-d $_) { if ($d_mode) { change_mode($_, $d_mode); } if ($d_owner) { change_owner($_, $d_owner); } if ($d_group) { change_group($_, $d_group); } } elsif (-l $_) { ... } elsif (-f $_) { ... } }

The point is that the different filetypes are exclusive: you're only interested in the first type that matches, so an if/elsif chain is appropriate. The updatetypes are not exclusive: you want to act on each updatetype that is specified, so you much check each of them without jumping out on the first one. An if/elsif chain is not appropriate for that case.

Hugo


In reply to Re^5: Permissions Utility Script for sysadmins - seeking comments by hv
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.