oryann9 <[EMAIL PROTECTED]> wrote:
"Dr.Ruud" wrote: Lawrence Statton XE2/N1GAK schreef:
> @{$aref2}[0] is 'sun'
ITYM:
${$aref2}[0] is 'sun'
--
Affijn, Ruud
"Gewoon is een tijger."
--
Ok everyone, I have thought about this one and tried various code changes but
cannot get what I want.
My problem: redundant UIDs in password files.
My solution:
#1 store passwd files in a globbed array
#2 create array reference from globbed array
#3 open array ref, create hash with more than one value per key. Keys are
regexps from filenames
#4 read in every line of passwd files from reference. Values in hash need to be
passwd entries
For example: key => servernames.platform (dubhpr01.hpux)
values => filelds from passwd file (name,uid,gid,comments)
#5 Once hash is built, traverse through searching for usernames that have
unlike UIDs from all files, then print these to an xls using
SpreadSheet::WriteExcel.
In my code I have completed 1,2 and 3. Started 4 but I am printing the array
reference address as opposed to printing the actual values. What am I doing
wrong and any tips would be nice? thank you
_OUTPUT_
KEY dubhst14.hpux
ELEMENTS /home/dbsmith/passwd.dubhst14.hpux
DUB VALUES root
KEY dubhdv05.hpux
ELEMENTS /home/dbsmith/passwd.dubhdv05.hpux
DUB VALUES root
dubhst14.hpux => ARRAY(0x4002b0f8)
dubhdv05.hpux => ARRAY(0x4059c9a4)
dubhadm3.hpux => ARRAY(0x4059c8f0)
dwhetls2.hpux => ARRAY(0x4002c164)
dubhadm1.hpux => ARRAY(0x4059c8a8)
oftappp1.hpux => ARRAY(0x405a2084)
dubhpr28.hpux => ARRAY(0x4002e1bc)
cic2.hpux => ARRAY(0x4059c6f8)
#!/usr/bin/perl
##-- Initialize environment --##
use strict;
use warnings;
use diagnostics;
use Spreadsheet::WriteExcel;
#use Data::Dumper;
$ENV{"PATH"} = qq(/usr/bin:/bin:/home/dbsmith:/home/dbsmith/McGaw);
delete @ENV{qw (IFS CDPATH ENV KSH_ENV BASH_ENV)};
##-- Central DIE routine --##
open (LOG, ">>/tmp/uid_ck.log") or warn "uid_ck.log did not open $!";
my $overide = $SIG{__DIE__}; ## get error handler currently assigned 2 die
$SIG{__DIE__} = sub {
my $error = shift; ## error now holds the mesg passed to die
$overide->($error) if ( ref $overide );
print LOG ($error);
};
##-- BEGIN MAIN --##
my @dublinaray = glob("/home/dbsmith/passwd.*");
my $dublin_aref = [EMAIL PROTECTED];
my @mcgawaray = glob("/home/dbsmith/McGaw/passwd.*");
my $mcgaw_aref = [EMAIL PROTECTED];
my (%dublin_hosts,%mcgaw_hosts) = ();
my ($dub_key,$dub_values,$mcg_key,$mcg_values);
parse_file();
sub parse_file {
foreach my $element ( @{$dublin_aref} ) {
{ local *FILE;
open (FILE, "+<$element") or die "dublin reference did not open: $!";
local $/ = undef;
($dub_key) = $element =~ m|\.(\w+\.\w+)\z|i;
($dub_values) = split /:/, ;
push ( @{$dublin_hosts{$dub_key}}, $dub_values );
print "KEY\t",$dub_key,"\n\n";
print "ELEMENTS\t",$element,"\n\n";
print "DUB VALUES\t",$dub_values,"\n\n";
}
}
while ( ($dub_key,$dub_values) = each %dublin_hosts ) {
print "$dub_key => $dub_values\n";
}
#foreach my $host (sort keys %dublin_hosts) {
# print "$host: @{$dublin_hosts{$dub_key}}\n";
#}
#foreach my $element2 ( @{$mcgaw_aref} ) {
# { local *FILE2;
# open (FILE2, "+<$element2") or die "mcgaw reference did not open: $!";
# local $/ = undef;
# ($mcg_key) = $element2 =~ m|\.(\w+\.\w+)\z|i;
# push (@{$mcgaw_hosts{$mcg_key}}, $mcg_values );
# print "\n$element2\n\n";
# print ;
# }
#}
} ##-- END SUB --##
Incorrect problem statement. Should read
My Problem: unalike UIDs in password files for users. example joe.brown uid
on server a is 1222 and uid on server b is 1198.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com