I have the following code:


%compilers = (
   system1 => "compiler_a",
   system2 => ["compiler_b", "compiler_c"],
   system3 => "compiler_d",
);

foreach $compiler (@{$compilers{$system}}) (
        $compiler_passwd = $compilers{$system} .
"_passwd";
        open ($compiler, "< $compiler_passwd") or die
"Can't open file $compiler_passwd: $!\n";
        while (<$compiler>) {
           chomp;
           @cmplr_data = (split(/:/))[0,1,2,4,5,6];
           ($cusername, $cpswd, $cuid, $cgecos,
$chome, $cshell) = @cmplr_data;
           push(@{$compiler_data{$cuid}}, $cusername,
$cpswd, $cgecos, $chome, $cshell);
        }
        close ($compiler) or die "Can't close file
$compiler_passwd: $!\n";
        open($compiler, "> $compiler_passwd") or die
"Can't open file $compiler_passwd: $!\n";
}

I don't want to duplicate code.  However, system2 has
two compilers and I need to read each compiler's
password file and store that data in a hash.  Now,
will  the compiler_data hash contain the data for both
compilers password files?  How can I keep them
separate and don't duplicate code?  






__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

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

Reply via email to