Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
On my Solaris 7 unix.
I am trying to fetch a unique name of html or htm owners. Basically get names of all our web authors and a total count.
From my "ls -l" I just need the owner of the html or htm file and get a person's name just once where I dont see two of the same names. For example if I get these names for all html or htm owners:
I am trying to fetch a unique name of html or htm owners. Basically get names of all our web authors and a total count.
From my "ls -l" I just need the owner of the html or htm file and get a person's name just once where I dont see two of the same names. For example if I get these names for all html or htm owners:
I only need unique names such as:Jones Jones Smith Smith Richards
My attempt to do it in Perl:Jones Smith Richards
#!/usr/local/bin/perl -w open STDERR, "> /dev/null" || die "Cant redirect standrd error: $!"; use File::Find; use strict; print "Web owners\n"; print "----------\n\n"; my $ct = 0; sub search { if( $_ =~ /\.html?$/) { $datetime = scalar(localtime(time)); my $name = $File::Find::name; open ( F, $name ) or die "$!: $name\n"; while(my $owner = <F>) { ($ownerid, $groupid) = (stat( "$owner" ))[4]; $ownerName = getpwuid($ownerid); { $ownerName{$1} = 1; } } close F; } } my $dirs = '/thisdirectory/directory'; find( \&search, $dirs)); foreach (keys %ownername) { print "$_\n"; } print "$ct\n";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Fetching unique owner name
by JaWi (Hermit) on Dec 03, 2002 at 13:35 UTC | |
by Anonymous Monk on Dec 03, 2002 at 14:52 UTC | |
by JaWi (Hermit) on Dec 03, 2002 at 17:14 UTC | |
by Anonymous Monk on Dec 03, 2002 at 18:55 UTC | |
by JaWi (Hermit) on Dec 03, 2002 at 19:08 UTC | |
| |
Re: Fetching unique owner name
by Callum (Chaplain) on Dec 03, 2002 at 13:28 UTC |
Back to
Seekers of Perl Wisdom