Recursively printing data structures in Perl

前端 未结 8 1904
粉色の甜心
粉色の甜心 2021-01-13 05:32

I am currently learning Perl. I have Perl hash that contains references to hashes and arrays. The hashes and arrays may in turn contain references to other hashes/arrays.

8条回答
  •  再見小時候
    2021-01-13 05:59

    Here is one simple example why your code is not easily readable:

    $delimiter = "\n--------------------------------------------" unless (defined $delimiter);
    

    You could use the defined or operator:

    $delimiter //= "\n" . '-' x 44;
    

    If you are worried about earlier Perls:

    defined $delimeter or $delimeter = "\n" . '-' x 44;
    

    Conditionals going off the right margin are enough of a turn-off for me not to read the rest of the code.

提交回复
热议问题