On Friday, June 13, 2003, at 12:01 PM, [EMAIL PROTECTED] wrote:

I am trying to split off the user name and the password record in one pass
through however what I am getting is only the first record is being
populated into my user array.


Can someone tell me am I going about this the right way?

Hmm, I don't think so.


my @user=(split(/:/,(@passwd=(split(/\n/,`cat /etc/passwd`)))[0]));

Okay, let's see what this is doing in English:


1.  Run `cat /etc/passwd`
2. Split the results of that on newlines
3. Store that in @passwd
# problems begin on the next step, I believe
4. Take the first entry of that array and split it on :
5. Store those results in @user

I'm not 100% sure how your /etc/passwd is formatted, but if the name is before the first colon and the password is after, we could populate a hash with something like:

my %users = map { (split /:/, $_)[0, 1] } grep !/^#/, split /\n/, `cat /etc/passwd`;

And print it with:

print "$_ $users{$_}\n" foreach keys %users;

for($i=0;$i <= $#passwd ; $i++)
{
print "$user[$i]\n";
print "$passwd[$i]\n";
}

Hope that helps.


James


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



Reply via email to