in reply to Returning a list from a sub
@Fields = /(\S*)\s+(\S*)\s+(\S*)(.*?)(\d.*)/;
Besides the improvements to your loop already suggested by VSarkiss, you can use array slices and the fact that "@array" will separate the values using $" which defaults to " " (a space) to eliminate all those temp variables and concatenations.
push @List, "@Fields[2,3,-1]"; # Fix the columns as necessary.
Finally, I'd suggest you read up on references and consider returning a reference to the array instead of the whole list.
-sauoq "My two cents aren't worth a dime.";
|
|---|