in reply to next if loop

I'd like to recommend getpwnam for this. Here we get a HoA keyed on user names, containing all the user info for each listed username.

my %users = map { $_ => [ getpwnam $_ ] } qw( adrian adm sys alcatel );
That eliminates all the fuss with the passwd file, to the benefit of portability.

After Compline,
Zaxo