The following script needs to loop through a file 
identifying users in each user group and the outputting 
that to a specific file.  In the end if I have 15 groups 
I should have 15 files.  However, when I loop I only get 
the last group outputted to the correct file.  What I 
think is happening is I am looping through Index 0 which 
is the group, but not index 1, which is the file.  I am 
sure it is printing only overwriting the file each time 
until it gets to the end.  I assume I need to use some 
sort of nested loop, but I am confused on which one 
(while, for foreach etc) and how to write it.  Here is 
the code and any help would be greatly appreciated.

Thanks

#!/usr/bin/perl -w

open 
FILEIN, "/usr/local/scripts/security/sybase/user/groups_f
iles.txt";
open 
ACCESSIN, "/usr/local/scripts/security/sybase/user/user_a
ccess_all.txt";
while (<FILEIN>) {
    chomp ();    
    @file = split /:/;
}

open OUT, ">$file[1]";
select OUT;

while (<ACCESSIN>) {
    chomp();    
    $user_access = $_;
    if (/$file[0]/) {
        print OUT "$user_access \n";
    }}    

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to