How to create multiple array variable in a loop

Discussion in 'Perl' started by kalaid, Oct 23, 2008.

  1. kalaid

    kalaid New Member

    Joined:
    Jul 21, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    In php code to create multiple array variable using loop and assign value will be as below

    for($i=0;$i<10;$i++)
    {
    $j=$i+1;
    $arr$j[$i]="some value";
    }
    Above code will create array variable from arr1 to arr10 and assign value.

    I want to convert same code to perl , how can i do this
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    Code:
    for($i=0;$i<10;$i++)
    {
      $j=$i+1;
      eval
      {
        \@arr$j[$i]="some value";
      };
    }
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice