simong has asked for the wisdom of the Perl Monks concerning the following question:
Hi all, i'm stucked on solve this situation: 2 arrays @a and @b containing both path elements. @a is quite heavy array of full path string;@b insted is a shorter array containing just a segment, a frame, of some of the elements in @a. Using (or not) a fast grep function, need to select the element in @a which satisfy (match)the content of @b. I try this , but not working:
%tmp = map{ $_ => 1 } @b; @inte = grep(!/$tmp{$_}$/, @a) ;
Any advise ? thanks Simon
Sorry I posted the wrong code, but in any case cant how to match $tmp variable
%tmp = map{ $_ => $_ } @b; @inte = grep(/$tmp{$_}$/, @a) ;
..in my intention would find, for every $_ of @a if any $_ of $tmp{$_} is part or $_ in @a
An example
@a = ('d:\1\1\1.txt', 'd:\1\1\2.txt', 'd:\1\1\3.txt', 'd:\1\1\4.txt')
@b = ('\1\2.txt', '\1\3.txt'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Dependant Arrays intersection
by Mr. Muskrat (Canon) on Feb 04, 2016 at 21:46 UTC | |
by simong (Initiate) on Feb 04, 2016 at 21:57 UTC | |
by Mr. Muskrat (Canon) on Feb 04, 2016 at 22:08 UTC | |
|
Re: Dependant Arrays intersection
by AnomalousMonk (Archbishop) on Feb 04, 2016 at 23:57 UTC | |
|
Re: Dependant Arrays intersection
by Discipulus (Canon) on Feb 04, 2016 at 21:48 UTC |