1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    Code:
    for($i=0;$i<10;$i++)
    {
      $j=$i+1;
      eval
      {
        \@arr$j[$i]="some value";
      };
    }
    
     

Share This Page