in reply to Re^2: Checking if all the key values are same in an Array
in thread Checking if all the key values are same in an Array

No. Your code checks if the value under "key1" of the second hashref in the array is false.

Consider:
#!/usr/bin/perl use strict; my @array = ( {key1=>0, key2=>2, key3=>3}, {key1=>1, key2=>2, key3=>3}, {key1=>0, key2=>2, key3=>3} ); my $amount = scalar(@array); if (!$array[0..$amount]->{key1}) { print "no\n" }
which should print "no" but does not, and
#!/usr/bin/perl use strict; my @array = ( {key1=>0, key2=>2, key3=>3}, {key1=>1, key2=>2, key3=>3}, {key1=>0, key2=>2, key3=>3} ); my $amount = scalar(@array); if (!$array[0..$amount]->{key1}) { print "no\n" }
which should not print "no" but does.


holli, /regexed monk/