Parse perl array

前端 未结 2 791
刺人心
刺人心 2021-01-27 06:14

I\'m not familiar with perl and am trying to edit an irssi translation script. The result from a web request returns as:

$result = {
 \"data\" => {
  \"transl         


        
2条回答
  •  失恋的感觉
    2021-01-27 06:46

    That would be

    $result->{data}->{translations}->[0]->{translatedText};
    

    $result is a hash ref. The key 'data' points at yet another hash ref, which has a key 'translations' pointing at an array ref. The first and only element in that array ref has a key 'translatedText' which points at the data of interest: 'Halloween'.

提交回复
热议问题