Greetings! I am trying to write a Perl script for the Cuyahoga Valley Scenic Railroad, so that volunteers can sign up to work on trains. The schedule file has comma-separated lines that have the date of the train, the name of the train, and the names of people who will be working on the train (or empty entries, if nobody has signed for that position yet). The date is a string of the form "MM.DD.YYYY". There can be one or more trains for each date. Currently, there are never more than two trains on one day, but I can't assume that, especially since I know we're extending our route next season and another extension could happen in a few years. I also can't assume that the number of positions per train will remain constant.
So, I am trying to build a data structure to hold the trains. I figure the best way would be to use a hash keyed by the date string. The values of the hash would be arrays, with one element per train. Each array would contain the list of positions for the train. I tried to use a data structure as described in Sam's Teach Yourself Perl in 21 Days. I am tripping over my own feet. Here's the code: while (<SCHEDULE>) { my ($trainsOnDate); chomp; # remove newline @trainData = split /,/; $trainDate = shift trainData; if (not exists $trainList{$trainDate}) { # Create the hash element, giving it an empty anonymous array $trainList{$trainDate} = []; } # Create a reference to the train data # $trainList{$trainDate} is a reference to the array of trains $trainRef = \@trainData; $trainsOnDate = \trainList{trainDate}; push $trainsList{$trainDate}, $trainRef; } close (IN); This gave me the following error: Type of arg 1 to push must be array (not hash element) at c:\INDIGO~1\HTDOCS\CREW\CALENDAR.CGI line 246, near "})" So how do I access the anonymous array the hash contains a reference to? Thanks! Rob __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]