in reply to Selective Check of Multiple Arrays With Single Construct
You've got several very good responses. Now here's a craptacular bit of code:
...roboticus#!/usr/bin/perl -w use strict; use warnings; my @arA = ('alpha', 'beta', 'delta', 'omega'); my @arB = ('alpha', 'foo', 'bar', 'omega', 'baz', 'beta'); my @arC = ('delta', 'grond', 'floo', 'delta', 'omega'); my @all = (); for my $elA (@arA) { my $idx=0; for my $elTest (@arB, @arC) { ++$idx; next unless $elA eq $elTest; if ($idx <= @arB) { push @all, $elTest . " - from Array B"; next; } $idx -= @arB; if ($idx <= @arC) { push @all, $elTest . " - from Array C"; next; } $idx -= @arC; # ... etc. } } print join("\n",@all);
|
|---|