Ok - sorry for the cheesy subject line but I couldn't resist.

So I am working on porting some interesting pieces of code I wrote in
p5 at the Monastery to p6 for the benefit of others - primarily to
show how easy the transition can be.

Since Pugs doesn't have p6 rules yet I wanted to show off the power of
junctions instead of using the pcre support.  Basically I need to know
if any character in string x matches any character in string y - easy
right:  $str =~ /[chars]/ becomes any( @x_chars ) eq any( @y_chars ). 
The problem is that in the regex version I use capturing parens to
identify the character matched.  For the purposes of the problem I
don't need to rely on the first character matched I just need to know
1.

Without doing a lot of research into junctions, I thought the
following would work:

my $matches = any( @x_chars ) eq any( @y_chars );
my $match = $matches.pick;

Ok - so maybe not - perhaps I should just change .pick to .values

hmmm - still not working - perhaps I need to give the junctions more
information as to what I am after

all( any() eq any() );

Hmmm - perhaps the problem isn't with junctions but with Pugs but to
know for sure I need to find out what, if anything, is the proper way
to do what I want.  The worst that could happen is that I find out
there isn't a way to get a what matched from an any() eq any()
comparison.

Cheers,
Joshua Gatcomb
a.k.a. L~R

Reply via email to