in reply to User input compared with generated list

You might want to check on Net::NIS. This module allows you to access the 'ypmatch' functionality directly, without having to do all that sorting and cutting. (Haven't used it myself, but the docs look promising.)

You'll also definitely want to use strict; and put a -w on your Perl invocation line. :)

stephen