hello,
 I am trying to test a key from a hash in a hash
the script gives me the desired result overall but i get
the warning ...
Use of uninitalized value in pattern match (m//) at ./passwd.pl line 26.
could someone tell me why i get this error

here is the code (this scrip looks at /etc/passwd and gets  info
from the desired field on a user - user and field args are passed on 
command line...


#! /usr/bin/perl -w
## fun with hash -- no pipe needed :)

$who = $ARGV[0];
$what = $ARGV[1];

unless($who && $what ){
        print "Usage - passwd.pl username field\n";
        print "Ex.  passwd.pl root uid\n";
        exit;
}

$file = "/etc/passwd";
open(PASS, "$file") || die "cant open file";
@array = <PASS>;
close(PASS);


for $i (@array){
        @_ = split(/\:/, $i);
        @fields = qw/user pass uid gid special home shell/;
        $name = $_[0];
        foreach $f (@fields){
                $hoh{"$name"}{$f} = shift(@_);
        }
}

## added \w test because roots uid is 0 therefor making tests false
if($hoh{$who}{$what} =~ /\w/){
        print "$hoh{$who}{$what}\n";
}

else{
        print "The combo $who and $what doesnt compute\n";
        print "Try again - Bye\n";
}


thanks,
-- 
jd
[EMAIL PROTECTED]

Bad spellers of the world untie!

"I can't tell if I have worked all my life or 
if I have never worked a single day of my life"
                        Miguel de Icaza


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to