Indexing directly into returned array in Perl

前端 未结 2 814
囚心锁ツ
囚心锁ツ 2021-01-01 17:38

This question has been asked about PHP both here and here, and I have the same question for Perl. Given a function that returns a list, is there any way (or what is the best

2条回答
  •  攒了一身酷
    2021-01-01 18:12

    Just use parentheses to define your list and then index it to pull your desired element(s):

    my $a = (split /,/, $comma_separated)[0];
    

提交回复
热议问题