in reply to Re^2: How do I create a C-like struct with dynamic fields in Perl?
in thread How do I create a C-like struct with dynamic fields in Perl?
Make an array with the struct? Like:
You don't really need a count of them, as you can use $# or @:my $struct= {pointers=>[]};
But then...if all you are storing is the array, you could just use it with no hash.$#{$struct->{pointers}} = last element index of pointers<br> @{$struct->{pointers}} = array
Or since you aren't using an index, both $#$ptrs and @$ptrs will work as well.$ptrs=[]; push @{$ptrs}=$newpointer; $#{$ptrs}; last index @{$ptrs}; array itself
or did you mean something else?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: How do I create a C-like struct with dynamic fields in Perl?
by man-et-arms (Initiate) on Jul 19, 2012 at 04:32 UTC | |
by Athanasius (Archbishop) on Jul 19, 2012 at 07:15 UTC |
In Section
Seekers of Perl Wisdom