Hi can you help please - i'm just having trouble mapping two group of entries.

My input file, has five teams with two group for each team (seperated by "/". I want to map if a member of a team, say Team1, from the first group (left side) is also present in any other team of the second group (right side), then i want to map the two teams. i.e. Joe is in Team1 and Team2, so map these together, but if a team member is found in only one side of the team is left unmaped. Please see input and the expect output below.

INPUTFILE Team1=Joe / Phil , Amenda Team2=James / Pam, Joe Team3=Carmen , Lisa / James Team4=Don , Phil / Carmen Team5=Uri , Kate / Don ------------------------ Expected OUTPUT Don IS IN Team5 AND Team4 Phil IS IN Team4 AND Team1 Carmen IS IN Team4 AND Team3 James IS IN Team3 AND Team2 Joe IS IN Team2 AND Team1

Here is my code, as you can see i'm not getting the correct mapping. even if i add the 'if statment' i can't seem to get the correct mapping

use Data::Dumper; open (my $infile, "<", "teamInput.txt") || die $!; while (defined(my $line = <$infile>)) { chomp $line; my @team = split /=/, $line; my ($a, $b) = split /\//, $team[1]; #member in group 1 and 2 split by + '/' my @x = split /\,/, $a; my @y = split /\,/, $b; my @results; for my $x1(@x) { for my $y1(@y){ #if ($x1 eq $y1){ push @results, [$team[0],$x1, $y1]; } } print join("\n", map { $_->[1] "$_->[0] AND $_->[0]" } @results), +"\n"; #print Dumper(\@results); } #}

Thank you for your time


In reply to Matching problem by jo26

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.