[EMAIL PROTECTED] wrote: > Hi All > > I have a textfile comprised of x number races each with x number of runners > eg. > > 13:00 > runner1 > runner2 > runner3 > runner4 > > 14:00 > runner1 > runner2 > runner3 > > 15:00 > runner1 > runner2 > > I want to put each race time into seperate array and each runner to be a > subset of particular array, the amount of arrays/runner in each file can > vary. The times of each race can also vary.
How about an hash of arrays, the data structre is of the format e.g. 15:00 is the hash key this key holds a reference to an array ("runner1", "runner2") If this is fine this code piece should do the job for you The assumption is that your race no is always of the format that you have specified use strict; use Data::Dumper; #Used to view the final data structure, remove it if you don't need it my %race_info = (); my $race_no; open (RACEFILE, $your_race_file) or die "Cannot open $race_your_file : $!\n"; while (<RACEFILE>) { chomp; next if (m/^$/); (m/^(\d+:\d+)$/) ? $race_no = $1 : push (@{$race_info{$race_no}}, $_); } print Dumper (\%race_info); > > > Any suggestions ?? > > Thanks in advance for any ideas.. > > Steve > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]