Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Declaring and checking content of variables with consecutive names

by Corion (Patriarch)
on Sep 23, 2016 at 11:36 UTC ( [id://1172454]=note: print w/replies, xml ) Need Help??


in reply to Declaring and checking content of variables with consecutive names

Don't.

The usual approach is to either use an array, @str, or a hash, %str.

Access them as:

my @str; $str[0] = ''; $str[1] = ''; ... $str[99] = ''; print join ",", @str;

or for the hash version:

my %str; $str{0} = ''; $str{1} = ''; ... $str{99} = ''; print join ",", map {$str{$_}} 0..99;

See also Why it's stupid to `use a variable as a variable name'

Replies are listed 'Best First'.
Re^2: Declaring and checking content of variables with consecutive names
by rflesch (Novice) on Sep 23, 2016 at 12:23 UTC
    Thank you very much! Very much appreciated!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1172454]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-24 00:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found