Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Declaring and checking content of variables with consecutive names

by Corion (Pope)
on Sep 23, 2016 at 11:36 UTC ( #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
Node Status?
node history
Node Type: note [id://1172454]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2019-09-17 05:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The room is dark, and your next move is ...












    Results (199 votes). Check out past polls.

    Notices?