array_intersect: allow passing list of references for convenience
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 23 Jul 2019 07:12:51 +0000 (09:12 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 23 Jul 2019 07:14:34 +0000 (09:14 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/Tools.pm

index a9addcd..676647e 100644 (file)
@@ -1654,6 +1654,10 @@ sub dev_t_minor($) {
 sub array_intersect {
     my ($arrays) = @_;
 
+    if (!ref($arrays->[0])) {
+       $arrays = [ grep { ref($_) eq 'ARRAY' } @_ ];
+    }
+
     return [] if scalar(@$arrays) == 0;
     return $arrays->[0] if scalar(@$arrays) == 1;