It is to some extend self explanatory. Perhaps you can
easily rearrange the output from the structure.


#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my @data = <DATA>; my $struct; my ($case, $table, $man, $seat, $round, $who, $what); for (@data){ /^\s*$/ and next; /^\s*#case\s+\w+:\s+(\d+)/i and $case = $1 and next; /^\s*people\s.+=\s*(\d+)/i and $table = $1 and next; /^\s*round\s+(\d+)/i and $round = $1 and next; /^\s*seat\s+(\d+):\s+(\w+)/i and ($seat, $man) = ($1, $2); /^(\w+)\s+(.+)?\s*$/ and ($who, $what) = ($1, $2); $struct->{$case}{$table}{'seat'}{$man} = $seat if $seat; push @{$struct->{$case}{$table}{'round'}{$round}{$who}}, $what if $ +round; } for my $case (keys %$struct){ for my $table (keys %{$struct->{$case}}){ for my $round (keys %{$struct->{$case}{$table}{'round'}}){ for my $man (sort keys %{$struct->{$case}{$table}{'round'}{$round}} +){ print "player: $man "; print "case: $case "; print "seat: $struct->{$case}{$table}{'seat'}{$man} "; print "round: $round "; print "QA: ", join '. ', @{$struct->{$case}{$table}{'round'}{$ro +und}{$man}}, "\n"; } } } } #print Dumper($struct); __DATA__ #Case Number: 12345 People at table = 5 Seat 1: Joe Seat 2: Steve Seat 3: Mary Seat 4: Jill Seat 5: Bob Jill speaks first Round 1: Jill says good Bob doesn't talk Joe says bad Steve says good Mary doesn't talk Jill says that's enough Mary talks for years Steve says that's not enough Round 2: Next question Jill says bad Bob doesn't talk Joe says bad Steve says bad Mary doesn't talk Bob says that's enough

Which has the following output:
player: Bob case: 12345 seat: 5 round: 1 QA: doesn't talk.
player: Jill case: 12345 seat: 4 round: 1 QA: says good. says that's enough.
player: Joe case: 12345 seat: 1 round: 1 QA: says bad.
player: Mary case: 12345 seat: 3 round: 1 QA: doesn't talk. talks for years.
player: Steve case: 12345 seat: 2 round: 1 QA: says good. says that's not enough.
player: Bob case: 12345 seat: 5 round: 2 QA: doesn't talk. says that's enough.
player: Jill case: 12345 seat: 4 round: 2 QA: says bad.
player: Joe case: 12345 seat: 1 round: 2 QA: says bad.
player: Mary case: 12345 seat: 3 round: 2 QA: doesn't talk.
player: Steve case: 12345 seat: 2 round: 2 QA: says bad.


In reply to Re: New to Perl by sh1tn
in thread New to Perl by Anonymous Monk

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.