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."
(Note, I haven't tested this.)#! /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
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 | |
|
Re: Re: How to do this in Perl ??
by blakem (Monsignor) on Nov 14, 2001 at 01:13 UTC | |
|
Re: Re: How to do this in Perl ??
by wube (Acolyte) on Nov 15, 2001 at 18:58 UTC |