Another way to handle is this not to change anything in the get_user_info() routine or its interface and use list slice to select which of the paramaters you want. This is a very handy technique in Perl with LOTS of applications. In this application, it allows you get to get rid of all this "undef" business.

Below second statement says give me 1st and 6th things in list. Normally I put the left hand parms in the order that program is going to use them and adjust the slice list according, ie  [5,0], [8,1..3,0], [0,-1] are all valid slices. -1 means last thing in list, -2 would be next to last thing in list. The main limitation is that a range cannot go backwards, 0..3 is ok, but 3..0 is not.

my ($locked,undef,undef,undef,undef,$expire)=$ssh->get_user_info($logi +nid); my ($locked,$expire) = ($ssh->get_user_info($loginid))[0,5];
Upate: a small point, I wouldn't use -1 in slice list here, using the absolute value of 5 allows more parms to be added without affecting existing code. But here is an example where -1 works GREAT!
my ($min,$max) = (sort @something)[0,-1];
Note that works even if there is only one thing in @something! It is ok for the last thing in the list to be the only thing in the list.

In reply to Re: Returning multiple values from subroutine by Marshall
in thread Returning multiple values from subroutine by walkingthecow

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.