in reply to Returning a list from a sub
The return value of a sub in Perl is the value of the last expression, or you can explicitly use a return statement. In this case, since there's only path through the sub, you can just do:
or to make things explicit:close(OUT); @List; }
Whichever you prefer.close(OUT); return @List; }
However, there are a couple of other improvements in your code which would make it simpler, easier, and more general.
while (<IN>) { s/,//; @Fields = split ' '; $Lable = $Fields[-2]; #sic -- should be "Label" $Slot = $Fields[2]; # You never set $Type, so the next line will get # a "use of undefined value" warning. push @List, "$Slot $Type $Lable"; } # You also never write anything to OUT
HTH
|
|---|