in reply to Extracting password from array

my @password_table = read_password_table(); sub get_password($$) { my ($userid, $database) = @_; my @matches = grep m/^$userid:.+:$database:/, @password_table; if ( @matches == 0 ) { warn "found no entries for $userid/$database"; return; } elsif ( @matches > 1 ) { warn "found multiple matches for $userid/$database"; return; } if ( $matches[0] =~ m/^$userid:(.+):$database:/ ) { return $1; } confess "some sort of logic error must have occurred"; }

Replies are listed 'Best First'.
Re^2: Extracting password from array
by robotball (Initiate) on Mar 29, 2010 at 20:52 UTC
    Doug, Could you explain your example in a little more detail? Specifically the last if statement?