I would like to have an array, its size will be passed as an argument in runtime. And I want to intialize it. How should I do? Thanks.
How to dynamically initialize an array
Collapse
X
-
Ok, so what have you tried thus far to do this? This sounds distinctly like school work. If it is, then you need to know that it is against this sites posting guidelines for you to post your homework and expect an answer.
What you are asking is rather fundamental and a quick Google search will help you do what you are asking. Any good "perl arrays" tutorial should explain these basic concepts.
Regards,
Jeff -
You don't have to allocate memory/buckets to arrays in perl if thats what you are thinking. Perl dynamically adds more buckets as needed and when needed. There might be special reasons to allocate some memory to an array before actually adding data into the array, but I don't know what those reasons might be.Originally posted by casybayI would like to have an array, its size will be passed as an argument in runtime. And I want to intialize it. How should I do? Thanks.Comment
Comment