in reply to naming array from a scalar

I have to name arrays according to scalar value

No, you don't. You have a XY Problem: you want to store those arrays somewhere for later use (X), and you think it would be convenient to name the arrays after each $var in turn, so you ask about that (Y).

But there is a better way to do what you want (X) - make a hash with keys of each $var content, whose value is the corresponding array. See perlref.

my %db_connections; foreach $val(@array){ $db_connections{ $val} = [ connection_to_database( $val) ]; }

You don't want to name arrays after a scalar value. Here's why.