How do I determine the number of elements in an array reference?

后端 未结 4 2021
名媛妹妹
名媛妹妹 2021-02-19 07:26

Here is the situation I am facing...

$perl_scalar = decode_json( encode (\'utf8\',$line));

decode_json returns a reference. I am sure this is a

4条回答
  •  青春惊慌失措
    2021-02-19 08:00

    $num_of_hashes = @{$perl_scalar};
    

    Since you're assigning to a scalar, the dereferenced array is evaluated in a scalar context to the number of elements.

    If you need to force scalar context then do as KARASZI says and use the scalar function.

提交回复
热议问题