How to get list of user into an array..

Hi,

cut -d: -f1,3 /etc/group >rpt.out

I have a doubt in above unix commands. right i am getting list of group user id into rpt.out file. instead i need to store it as an array. could you please tell me how can i get list of user into an array..

If u could tell me give me in perl script code in unix

thanks in advance.

bash

A=( $(cut -d: -f1,3 /etc/group | tr '\n' ' ') )
echo "Number of elements in array: ${#A[@]}"
echo "Elements of array: ${A[@]}"

To emulate cut:

open my $group, '<', '/etc/group';
my @groups = map { my @a = split /:/; $a[0] . ':' . $a[2] } <$group>;
close $group;

To create a hash mapped on the group name:

open my $group, '<', '/etc/group';
my %groups = map { my @a = split /:/; $a[0], $a[2] } <$group>;
close $group;