Problem: Given an old and a new org-chart, arrange meetings between old and new team leaders so that for each person in each new team they can hand over HR documents and discuss any current performance issues etc.

Answer 1: Grind out a matrix by hand

Answer 2: Perl!

Submitted as a CUFP for to bringing perl to the realm of pointy haired bosses.

use strict; use warnings; my %old=( # 'Old Team Leader' => ['list','of','persons','reporting','to','this +','team','leader'] 'Beatrice' => ['Charles','Andrei','Ian','Patritzia','Violet','Mart +in','Norbert','Oliver','Mark','Harriet','David'], 'Fran' => ['John','Tracy','Albert','Larry','George','Marvin','Jam +es','Ray'], 'John' => ['Inigo','Kalen','Juliet'], 'Albert'=> ['Dean','Andrew'], 'Edward' => ['Charles','Randall','Robert','Colin'], 'Charles' => ['Shawn','Jon'], 'Daphne' => ['Beatrice','Fran','Wayne','Edward'] ); my %new=( # 'New Team Leader' => ['list','of','persons','reporting','to','this +','team','leader'] 'Charles' => ['Oliver','Norbert','Mark','Robert'], 'David' => ['Newboy','Randall'], 'Edward'=> ['Andrew','Patritzia','Larry','Tracy','Albert'], 'John' => ['Martin','Inigo','Juliet','Kalen'], 'James' => ['Fran','George','Jon','Shawn'], 'Beatrice' => ['Wayne','Charles','David','Edward','Dean','John','J +ames'], 'Edward' => ['Harriet','Ray'] ); my @nobody = (); sub oldreports { @{$old{$_[0]} || \@nobody}; } sub newreports { @{$new{$_[0]} || \@nobody}; } sub oldtl { my $who=shift; for my $lm (keys %old) { for my $rep (oldreports($lm)) { return $lm if ($who eq $rep); } } return ''; } for my $newtl (sort keys %new) { my %needtomeet; for my $rep (newreports($newtl)) { my $oldtl=&oldtl($rep); push @{$needtomeet{$oldtl}},$rep if ($oldtl); } print "\n$newtl needs to meet with "; for my $oldtl (keys %needtomeet) { next if ($oldtl eq $newtl); print "\n\t$oldtl to discuss\n"; for my $reps ($needtomeet{$oldtl}) { for my $rep (@$reps) { next if (($rep eq $newtl) or ($rep eq $oldtl)); print "\t\t$rep\n"; } } } }

In reply to Restructuring Teams with Perl by EdwardG

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.