The unix version of "chgrp" is not a script. It is compiled C code, and if you are choosing between running a perl version of chgrp via "system()" vs. running the unix version of chgrp via "system()", I think you'll be much better off running the unix version.

I noticed that the perl version of "chgrp" uses the File::Find module to handle the "-R" (recursive descent into subdirectories) option, and I have to admit that File::Find is one of my pet peeves -- a module with a fairly counter-intuitive, byzantine usage and remarkably slow performance, relative to other techniques for doing the same thing.

Even if you take the trouble to understand the code in the perl version of chgrp, and decide to do a "copy / paste / modify" sort of migration of that code into your own app (this is certainly doable -- it's just not as simple as "use ..." or "require ..." or "do ...", because you really have to copy a subroutine into your script and work out the logic for calling it), even so, the performance of resulting pure-perl approach to changing group ownership on files is going to be noticeably slower than running a system call to the unix version of "chgrp".

So, assuming that you really are on a unix box, I don't know why you are fixating on a pure-perl approach here. (If you aren't on a unix box, I'm not sure what it would mean to do "chgrp" anyway.)


In reply to Re: HELP chgrp by graff
in thread HELP chgrp by Ronnie

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.