Hi all

In the following sub, I want to return the list @List to the calling sub. How do I do this?

sub TSM_Enquire { my $Record, $Slot, $Type, $Label; my @List; open(IN,"adsm_cmd q libv|grep 3584|"); open(OUT,">/tmp/show_library.$$"); while ($Record = <IN>) { $Record =~ s/,//; @Fields = split(' ', $Record, 9999); $Lable = $Fields[$#Fields-1] $Slot = $Fields[2]; push(@List, $Slot . " " $Type . " " . $Lable); } close(IN); close(OUT); }
"adsm_cmd q libv|grep 3584" returns
<snip> 3584LIB1 922ABL Private Data 1,036 3584LIB1 923ABL Scratch 1,100 3584LIB1 924ABL Private Data 1,076 3584LIB1 925ABL Private Data 1,030 3584LIB1 926ABL Private Data 1,078 3584LIB1 938ABL Private Data 1,025 3584LIB1 939ABL Private Data 1,037 3584LIB1 CLNI88 Cleaner 1,026 3584LIB1 CLNI89 Cleaner 1,038 </snip>
To finish up, I want to return the list containing slot, type and label to the calling function and the the calling function needs to loop through the list and take various actions depneding on the slot range and type.
TIA
coec

In reply to Returning a list from a sub by coec

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.