Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > dynamically substituting variable name

Reply
Thread Tools

dynamically substituting variable name

 
 
mostart
Guest
Posts: n/a
 
      07-17-2003
hi,

I want to dynamically substitute a variables name.
I know this from PHP where you can have somthing like
${$foo}

how can I do this in perl ??

thanks
mostart
 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      07-17-2003
mostart wrote:
> I want to dynamically substitute a variables name.
> I know this from PHP where you can have somthing like
> ${$foo}
>
> how can I do this in perl ??


You may want to check The Fine Manual about why it's a bad idea to use
symbolic references and what better options are available: perldoc -q
'variable name'

How can I use a variable as a variable name?
Beginners often think they want to have a variable contain the
name of a variable.
[...]
This works *sometimes*, but it is a very bad idea for two
reasons. [...]

jue


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Variable variable name" or "variable lvalue" mfglinux Python 11 09-12-2007 03:08 AM
substituting variable for an attribute brahatha Java 0 06-06-2007 03:48 PM
adding a variable name to a hash to name is part of the variable name Bobby Chamness Perl 2 04-22-2007 09:54 PM
How do I scope a variable if the variable name contains a variable? David Filmer Perl Misc 19 05-21-2004 03:55 PM
substituting values in property file Andy Fish Java 2 12-29-2003 05:11 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57