CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Fun With Perl: Perl Quizzes - Learn Perl the Fun Way:
perl dyname variable name help


New User

Aug 8, 2011, 11:30 PM

Post #1 of 2 (38524 views)
perl dyname variable name help Can't Post

Hi every one:

I been looking for solution dynamically create a variable name.
something like this:

my new21MO = "testing";
my $number = 21;
my $exName = "MO";

my $string = "new" . $number . $MO;
print $$string; <------------- I tested this aren't working.

is there a way to declare this string to a variable?
please help me out.

Veteran / Moderator

Aug 10, 2011, 9:39 AM

Post #2 of 2 (38488 views)
Re: [chefchanyu] perl dyname variable name help [In reply to] Can't Post

What you're asking about is called symbolic references and using them is a very bad idea.

Use a hash instead of symbolic references.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives