Yet another problem from Intermediate Perl, I've been given a log file. Here is a sample of its contents:
Gilligan: 1 coconut Skipper: 3 coconuts Gilligan: 1 banana Professor: 3 coconuts MaryAnn: 2 papayas Thurston: 2 mangoes I am supposed to read the log file and output its contents into a series of files called gilligan.info, maryann.info, etc. In the end I should I have a .info file for each character. In the file will be information pertaining to the character. For example, gilligan.info will have Gilligan: 1 coconut Gilligan: 1 banana According to the book, I'm supposed to process the file in one pass and then output the files in parallel. Here is what I have written so far: #!/usr/bin/perl -w use strict; use IO::File; my $castaway; my %total_fruit; while (<>) { if (/(^\S+):/) { $castaway = $1; $castaway =~ tr/A-Z/a-z/; my $castaway_fh = $castaway.".info"; $total_fruit{$castaway} = IO::File->new($castaway_fh); print {$total_fruit{$castaway}} $_; } } This script generated the following error message: Can't use an undefined value as a symbol reference at read_log.pl line 15, <> line 1. What does the message mean? I must admit I am confused by book's instructions. I don't understand what the book means when it wants me to "write all ouput files in parallel". -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/