[pve-devel] [PATCH common] replace the smartmatch operator
Dietmar Maurer
dietmar at proxmox.com
Thu May 12 11:36:22 CEST 2016
I prefer the following code:
my @f100 = sort @{$ifaces->{vmbr0}->{families}};
die "invalid families defined for vmbr0"
if (scalar(@f100) != 2) || ($f100[0] ne 'inet') || ($f100[1] ne 'inet6');
> +# Compare two arrays of strings
> +sub strarray_equals($$) {
> + my ($left, $right) = @_;
> + return ref($left) && ref($right) &&
> + ref($left) eq 'ARRAY' &&
> + ref($right) eq 'ARRAY' &&
> + scalar(@$left) == scalar(@$right) &&
> + !grep { $left->[$_] ne $right->[$_] } (0..(@$left-1));
> +}
> +
More information about the pve-devel
mailing list