On 6/13/07, Gian Sartor <[EMAIL PROTECTED]> wrote:
Hi All,

I have a list in the following format ->

room
surname
firstnames

What I would like to is read the file into an array and combine the
firstname and surname onto the same line and ignore the room. Below is
an example of what I want to do ->

#!/usr/bin/perl

use strict;
use warnings;

while (1) {
       #FIXME:this code needs to use the err operator instead of
       #the or operator, but it doesn't exist until Perl 5.10
       my $room   = <DATA> or last;
       my $lname  = <DATA> or die "could not read a complete record";
       my $fname  = <DATA> or die "could not read a complete record";
       chomp($room, $lname, $fname);
       print "$lname, $fname in room $room\n";
}
__DATA__
100
Wall
Larry
101
Conway
Damian
102
Christensen
Tom
103
Schwartz
Randal

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


Reply via email to