Select with test function that depends on # [duplicate]

This question already has an answer here:

I'm trying to teach myself to use pure functions and slots as much as possible. Here is my problem.

I have a list:

RandomSeed;
l = RandomInteger[{1, 10}, 20]
(*{3, 6, 1, 4, 4, 6, 1, 6, 3, 6, 8, 10, 8, 7, 5, 4, 8, 4, 4, 8}*)

Now I want to select all elements that equal 1 by using Select:

Select[l, # == 1 &]
(*{1, 1}*)

Then I want to get two lists, one with 8s and second with 1s:

test[p_] := p == # &;
Select[l, test[#]] & /@ {8, 1}
(*{{8, 8, 8, 8}, {1, 1}}*)

How can I do it without introducing test[p_]? In other words I need Select's second argument to depend on "another" slot #, not the one that will be substituted by list elements during iteration. The closest question I was able to find is Second level depth pure function?, but I think my question is slightly different, because I don't have to put slot in the first argument of Select

Thanks a lot to everybody who answered in comments.

leo[l_] := Reap[Sow[#, #] & /@ l, 1 | 8, #2 &][];
jm[l_] := Function[p, Select[l, # == p &]] /@ {8, 1};
kgl[l_] := Select[l, Function[x, x == #]] & /@ {8, 1};
mar[l_] := With[{p = #}, Select[l, # == p &]] & /@ {8, 1};

Out of curiosity I decided to run simple benchmark to check performance

Benchmark[f_, n_] := Module[{l, results, samples},
RandomSeed;
samples = Table[RandomInteger[{1, 100}, n], {10}];
results = Table[First@AbsoluteTiming[f[l]], {l, samples}];
Mean[results]];
testRange = 10^# &@{3, 4, 5, 6};
TableForm[
Table[Benchmark[fun, n]/n, {fun, {leo, jm, kgl, mar}}, {n,
testRange}],
TableHeadings -> {{"leo", "jm", "kgl", "mar"}, testRange}] The results are normalized over list length. Interestingly kgl[] is about two times slower than jm[].

IMHO the Select[l, Function[x, x == #]] & /@ {8, 1} (by @kglr) is the most visually appealing.

It was also asked why do I care if all I need is just making two simple Selects?

I think it's more clear and concise to have one line that does something twice rather than having two almost identical lines. My original example is oversimplified probably.

Imagine I want to select all prime numbers and also all numbers that are prime squared. If I use syntax by @kglr I can do

{primes, primeSq} =
Select[l, Function[x, #[x]]] & /@ {PrimeQ, PrimeQ@Sqrt[#] &}

Which is very self explanatory.