wap has asked for the wisdom of the Perl Monks concerning the following question:

The object of this project is to develop a Perl script (orph_find.pl) for looking for orphaned homes (home directories without users, or the inverse).
This script should generate a formatted listing of
any user without a home directory...
...or any home directory (a directory in /home) that is not attached to a user.
Remember that the identifying element is the UID, not the username.

i keep getting this error :

Array found where operator expected at ./orph.pl line 20, near "} " (Missing operator before ?) Not enough arguments for grep at ./orph.pl line 20, near "grep |" syntax error at ./orph.pl line 20, near "$eval{" Execution of ./orph.pl aborted due to compilation errors.

#! /usr/bin/perl uid1; uid2; while(($uid) = getpwent()) { push(@uid1, $uid); } print " passwd users: @uid1\n"; opendir(DIR,'/home') or die "error opening home dir"; #foreach my $none(readdir(DIR)){ if($none = n(/^\./)) { next #; #} push(@uid2, $none); print "home Directory Elements :@uid2\n"; closedir(DIR); } @eval { map {lc} @uid1} = (); @uniqueElements = grep |e $eval{lc $_} @uid2; print "not in either locations:@uniqueElements\n"; exit;

Replies are listed 'Best First'.
Re: orphaned users
by hippo (Archbishop) on Apr 26, 2018 at 14:45 UTC

    Welcome to the monastery, wap.

    The statement @uniqueElements = grep |e $eval{lc $_} @uid2; is not valid syntax. Perhaps you could explain what you understand this line to be doing?

    You also need a closing </code> tag in your post in order to make it legible. See How do I change/delete my post?