How to dynamically initialize an array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • casybay
    New Member
    • Oct 2007
    • 35

    #1

    How to dynamically initialize an array

    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.
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    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

    Comment

    • KevinADC
      Recognized Expert Specialist
      • Jan 2007
      • 4092

      #3
      Originally posted by casybay
      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.
      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.

      Comment

      Working...