How can I resolve this case of “Useless use of a variable in a void context”?

前端 未结 3 1725
一整个雨季
一整个雨季 2021-02-19 00:17

How can I resolve this case of \"Useless use of a variable in a void context\"?

For example:

  my $err = $soap_response->code, \" \", $soap_response-&         


        
3条回答
  •  逝去的感伤
    2021-02-19 00:47

    my $err = join(' ', $soap_response->code, $soap_response->string) . "\n";
    

    or, better IMO:

    return sprintf "%s %s\n", $soap_response->code, $soap_response->string;
    

    See perldoc -f join and perldoc -f sprintf perldoc perlop.

    Regarding the warning, see perldoc perlop and this note on the comma operator.

提交回复
热议问题