On Jul 9, 2:04 pm, [EMAIL PROTECTED] (Klute) wrote:

> Here is the sample data:

That helps us provide a meaningful reply.  Something like this will
work, though you may want to make the regexp's a little more
generalized:

#!/usr/bin/perl
   use strict;

   my (%affiliate, $parent, $group);
   while (<DATA>) {
      /Affiliate Parent Group: (.*)\n/ and $parent = $1 and next;
      /Affiliate Group: (.*)\n/        and $group = $1  and next;
      /Affiliate \(Aff Id: (\d+), Aff Name: (.*)\)/ and
            $affiliate{$parent}{$group}{$1} = $2;
   }

   print $affiliate{'Google'}{'Google Publisher'}{'3'};  #prints
'Lori'

__DATA__
Affiliate Parent Group: Google
  -> Affiliate Group: Google Advertiser
     --> Affiliate (Aff Id: 1, Aff Name: Frank)
     --> Affiliate (Aff Id: 2, Aff Name: Mary)

  -> Affiliate Group: Google Publisher
     --> Affiliate (Aff Id: 3, Aff Name: Lori)
     --> Affiliate (Aff Id: 4, Aff Name: Mike)

Affiliate Parent Group: Yahoo
  -> Affiliate Group: Yahoo Advertiser
     --> Affiliate (Aff Id: 5, Aff Name: Marlene)
     --> Affiliate (Aff Id: 6, Aff Name: Larry)
  -> Affiliate Group: Yahoo Publisher
     --> Affiliate (Aff Id: 7, Aff Name: Alex)
     --> Affiliate (Aff Id: 8, Aff Name: Glenn)



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to