"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!
In reply to Re: How to do this in Perl ??
by VSarkiss
in thread How to do this in Perl ??
by wube
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |