in reply to How to do this in Perl ??

"Can it be done in Perl"? Do we need to discuss Turing-completeness? I think what you mean to ask is "How easily can this be done in Perl?" to which the answer is, "Very easily."

#! /usr/bin/perl -w use strict; my $wkdir = '/var/sadm/install'; chdir $wkdir or die "Couldn't cd to $wkdir: $!\n"; open I, 'contents' or die "Couldn't open 'contents': $!\n"; my @line; while (<I>) { next if m{/usr d|/usr/lib d|/usr/openwin d}; if (/ d /) { @line = split; system("chown -R $line[4]:$line[5] $line[0]"); } } close I; # be polite
(Note, I haven't tested this.)

As always, TIMTOWTDI. (This may even touch off a round of golf. ;-) Notice I didn't write the chown commands to a script, I just executed them directly. There are other optimizations possible, but I just wanted to make the correspondence to your script very clear.

HTH

Update
Changed cd to chdir. Thanks, blakem!

Replies are listed 'Best First'.
Re: Re: How to do this in Perl ??
by belg4mit (Prior) on Nov 13, 2001 at 21:47 UTC
    You can take a few strokes off by inserting use File::Find; after line 2 and replacing system(...) with
    find(sub { chown($line[4], $line[5], $File::Find::name); }, $line[0]);
    pop; pop(@FIZZ); @FIZZ;
Re: Re: How to do this in Perl ??
by blakem (Monsignor) on Nov 14, 2001 at 01:13 UTC
    One minor point:

    cd is spelled chdir in perl...

    -Blake

Re: Re: How to do this in Perl ??
by wube (Acolyte) on Nov 15, 2001 at 18:58 UTC
    I will play with this.
    Thanks to all that replied
    wube