in reply to Creating variables for each array member

While this is possible, you don't want that. Read Why it's stupid to use a variable as as a variable name to get a discussion of the perils and the solutions.

You should put your data into an array instead of collecting it into numbered variables.

I'm quite confident that somebody will show you the way how to use strings as variable names, but you shouldn't use that but first think long and hard about the problem you're trying to solve, and the alternatives that Perl offers you, like hashes and arrays. If an array does not suit your needs, then a hash sure will:

my %numbers = ( num1 => 1, num2 => 2, ... num10 => 10, ); # which can be constructed programmatically as: my %numbers = map { "num$_" => $_ } (1..10);

Replies are listed 'Best First'.
Re^2: Creating variables for each array member
by Marsel (Sexton) on Jul 25, 2006 at 09:48 UTC
    That's a really interesting answer ! thanks !
    i've also asked myself a lot of time how i could do that, and never thought it could be so buggy. From your link, my answer to this :

    On the other hand, I could try to answer on a different level, present a better solution, and maybe slap a little education on `em. That's nice when it works, but if it doesn't it's really sad to see your hard work and good advice ignored.
    I really do prefer when people just tell me i'm on a wrong way, the time you think you lose in learning a new concept isn't losed most of the time.

    A huge thank to all people who take time for this !

    Marsel