in reply to New to Perl

Wow, thanks alot for such quick responses....let me be a little more clear about how an output should look.

Given the data snippet I used above I would like there to be 5 space deliniated rows of output (one for each player, I put commas here so it was clear which items where seperate). These rows will then be sent to a spreadsheet that is happy to import text files that are space deliniated. For example, this would be the perfect output for me for one player:

Player_Name, Case#, Seat#, Speaking_Position, First_response_to_Question_1, Second_response_to_Question_1, Question_For_Round_2, First_response_to_Question_2, Second_response_to_Question_2,

If there is no data for the Second_response field I would like there to be a 0 (for example in my real data people can answer up to 5 times, but usually they only give 2 or 3 responses and I'd like to fill the placeholders for extra responses with 0).
So for Joe the output would look like this ideally (he is third to speak if we start with Jill):

'Joe' , '12345' , '1' , '3' , 'bad' , '0' , 'Next Question' , 'bad' , '0'

And I would get an output like this for each person at the table.

Thanks again for the help, you folks are certainly helping me feel that this is a reasonable thing to accomplish as a beginner.

Replies are listed 'Best First'.
Re^2: New to Perl
by Random_Walk (Prior) on Jan 20, 2005 at 22:10 UTC

    Here is a more readable version with comment. I now include speaker order and made the output a little more readable. The problem pointed out by Chromatic is also fixed in this version

    #!/usr/bin/perl # the folllowing check your code for you # enforce some good behaviour (like declaring variables) # and catch a lot of finger pilotage errors use warnings; use strict; # here I declare some variables I am going to use # $ is a scalar (string, number, or a reference to another variable) # @ is an array of scalars # % is an associative array or hash, values looked up by a unique key my ( $case_number, $head_count, @player, $spoke_first, %player_said, $round );

    Cheers,
    R.

    Pereant, qui ante nos nostra dixerunt!
Re^2: New to Perl
by Random_Walk (Prior) on Jan 20, 2005 at 18:46 UTC

    This is not pretty but it is functional. I missed out the speaking order part and the seperation of reading from outputing makes the code far more complex than required. I will try to make a better example later, but I've written it so here goes.