in reply to Re: ~username expansion
in thread ~username expansion

You may wish to look at the getpwnam() function to get the directory entry for you, such as in the following example:

#!/usr/bin/perl -w use strict; ( my $name, my $passwd, my $uid, my $gid, my $quota, my $comment, my $gcos, my $dir, my $shell, my $expire ) = getpwnam('user'); # Insert '(undef)' if variable is undefined. foreach my $x ( \$name, \$passwd, \$uid, \$gid, \$quota, \$comment, \$gcos, \$dir, \$shell, \$expire ) { ${$x} = '(undef)' unless ( defined( ${$x} ) ); } printf <<OUTPUT, $name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, + $shell, $expire; getpwnam() OUTPUT: name: %s passwd: %s uid: %s gid: %s quota: %s comment: %s gcos: %s dir: %s shell: %s expire: %s OUTPUT

According to the docs for the function, a null list would be returned if the user did not exist.

Hope that helps.