In Perl, is there a built in way to compare two arrays for equality?

后端 未结 13 2395
无人及你
无人及你 2020-11-27 17:08

I have two arrays of strings that I would like to compare for equality:

my @array1 = (\"part1\", \"part2\", \"part3\", \"part4\");
my @array2 = (\"part1\", \         


        
13条回答
  •  情书的邮戳
    2020-11-27 17:34

    If casing is the only difference, you can simply use:

    if (lc "@array1" eq lc "@array2") {...}
    

    Whereas "@array1" returns the same as join ( " ", @array1 )

提交回复
热议问题