perl - Efficient way to check if elements of an array is a substring of elements in another array -
i have 2 arrays:
@array1containsblah1throughblah100.@array2containsname: creating "blah1"throughname: creating "blah100".
i need check each element @array1 in @array2 name: creating part getting in way.
what best route make sure elements @array1 in @array2?
maybe use of regexes matching while looping through @array1 against @array2?
there faster way?
do array_diff, intersect, or unique work when there noisy string in 1 of arrays?
or
maybe manipulate @array2 gets rid of name: creating part each data?
which way faster?
die if @array1 != @array2; (0..$#array1) { die if $array2[$_] ne qq{name: creating "$array1[$_]"}; } or if name part variable,
die if @array1 != @array2; (0..$#array1) { die if $array2[$_] !~ /: creating "\q$array1[$_]\e"$/; }
Comments
Post a Comment