in reply to finding a value in a list

First of all, you don't really need the output.txt file, you can redirect the output of your command to the perl script as in $ sudo dscl . list groups gid | program.pl and read the data from stdin (while(<>)) without the need of open and close.

To parse the lines you can use a regex match like this> $_ =~ /^\s*(\S+)\s*(\d+)\s*$/; if the line matches, you'll find the group name in $1 and the ID in $2.

Updated: corrected a type in the first code line. Thanks to toolic and, no, I don't know if mac is very different from unix, but this keyboard I'm using today is very different from my own! :-)

Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."