Sherlock has asked for the wisdom of the Perl Monks concerning the following question:
You'll notice that the Day struct contains an array which I intend to be an array of Appt structs. I then have an array of Day structs (and a counter), like this:struct Appt => { startTime => '$', endTime => '$', }; struct Day => { date => '$', appts => '@', numAppts => '$', };
I seem to be able to add Day structs to my array, days, like this:my @days; my $dayCount = 0;
Unfortunately, I'm unable to add any elements to the appts array within the Day struct. This is the code I'm currently trying to use to add a new Appt struct to the appts array:sub hdl_start { my ($p, $elt, %atts) = @_; if ( $elt eq 'DAY' ) { # Create a new Day struct my $temp = Day->new(); # Set the date element of that struct $temp->date($atts{"DATE"}); # Insert that struct into my array, days $days[$dayCount] = $temp; } $currEle = $elt; }
The error I am given looks like this: syntax error at line 81, near "->appts[". (Line 81 is the final line of code listed above.)# Get the number of appointments my $numAp = $days[$dayCount]->numAppts; # Create a new Appt struct my $temp = Appt->new(); # Set the startTime element within my new Appt struct $temp->startTime("$str"); # Insert my new Appt struct into the appts array $days[$dayCount]->appts[$numAp] = $temp;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Syntax Error with Embedded Structs
by princepawn (Parson) on Apr 18, 2001 at 00:50 UTC | |
by tye (Sage) on Apr 18, 2001 at 02:56 UTC | |
|
Re: Syntax Error with Embedded Structs
by arturo (Vicar) on Apr 18, 2001 at 01:00 UTC |