in reply to Returning multiple values from subroutine
Edit: actually, I prefer the suggestion as given by roboticus just below.
One approach would be to, you know... specify the things you want back - and in what order.
my ($locked, $expire) = get_user_info( loginid => $loginid, info => [qw(locked expire)] ); # elsewhere... sub get_user_info { my %args = @_; my $loginid = $args{loginid} or die "No login id"; my @return; for my $return ( @{ $args{info} } ) { if ($return eq "locked") { my $locked = ...; push @return, $locked; } elsif ($return eq "pw_min_time") { my $pw_min_time = ...; push @return, $pw_min_time; } ... # I'm sure you get the pattern } return @return; }
|
|---|