in reply to List all Users Directory

Hi valerydolce,

There are better solutions than the following (e.g. eyepopslikeamosquito's post), but since nobody has mentioned it yet, for completeness here are two solutions that actually access the file system and list directories. One of the problems with this is that there may be stray directories present that do not map to users; I've also hardcoded the "DUMMIES" name. In the second solution, I'm also showing something that I would normally recommend against: using a regex on a pathname, in this case it might be justified if you know you'll only be working with *NIX pathnames.

use Path::Class qw/file dir/; my @homes = ( grep({$_->is_dir && $_->basename ne 'DUMMIES'} dir('/home')->child +ren), grep({$_->is_dir} dir('/home/DUMMIES')->children) ); use File::Spec::Functions qw/splitdir/; # core module my @homes2 = ( grep({-d && (splitdir($_))[-1] ne 'DUMMIES'} glob '/home/*'), #OR: grep({-d && !m#/DUMMIES$#} glob '/home/*'), grep({-d} glob '/home/DUMMIES/*') );

Hope this helps,
-- Hauke D