![]() |
enlarge Variablenames
my Problem ist following:
$nr1 = 1; $nr2 = 2; $name.$nr = "Hello"; I have tried following way: ${"name".$nr} = "Hello"; But it doesn´t work. Is there another way to solve my problem? greetings |
Re: enlarge Variablenames
On Tue, 15 Jun 2004, Ugur Boss wrote:
> my Problem ist following: > > $nr1 = 1; > $nr2 = 2; > > $name.$nr = "Hello"; > > I have tried following way: > > ${"name".$nr} = "Hello"; > > But it doesn´t work. Is there another way to solve my problem? You haven't described what your problem is. What exactly are you trying to achieve? Note that I'm going to make a *guess* that you are trying to use a variable as a variable name. This is A Bad Idea. For more information on why this is A Bad Idea, and how to do what you *should* do instead, please read the FAQ entry "How can I use a variable as a variable name": perldoc -q 'variable name' Paul Lalli |
Re: enlarge Variablenames
Ugur Boss wrote:
> my Problem ist following: > > $nr1 = 1; > $nr2 = 2; > > $name.$nr = "Hello"; This is not Perl. Are you thinking about a "record" like in Modula or Pascal? The closest Perl data structure would be a hash: $name{$nr} = "Hello"; jue |
Re: enlarge Variablenames
I try to enlarge the variablename of my scalar $name so that i have
later a variable named $name666 or $name999 with the value "Hello". Paul Lalli schrieb: > On Tue, 15 Jun 2004, Ugur Boss wrote: > > >>my Problem ist following: >> >> $nr1 = 999; >> $nr2 = 666; >> >> $name.$nr = "Hello"; >> >>I have tried following way: >> >> ${"name".$nr} = "Hello"; >> >>But it doesn´t work. Is there another way to solve my problem? > > > You haven't described what your problem is. What exactly are you trying > to achieve? > > Note that I'm going to make a *guess* that you are trying to use a > variable as a variable name. This is A Bad Idea. For more information on > why this is A Bad Idea, and how to do what you *should* do instead, please > read the FAQ entry "How can I use a variable as a variable name": > > perldoc -q 'variable name' > > Paul Lalli |
Re: enlarge Variablenames
[please post your replies *below* the text you are replying to]
On Tue, 15 Jun 2004, Ugur Boss wrote: > Paul Lalli schrieb: > > > On Tue, 15 Jun 2004, Ugur Boss wrote: > > > > > >>my Problem ist following: > >> > >> $nr1 = 999; > >> $nr2 = 666; > >> > >> $name.$nr = "Hello"; > >> > >>I have tried following way: > >> > >> ${"name".$nr} = "Hello"; > >> > >>But it doesn´t work. Is there another way to solve my problem? > > > > > > You haven't described what your problem is. What exactly are you trying > > to achieve? > > > > Note that I'm going to make a *guess* that you are trying to use a > > variable as a variable name. This is A Bad Idea. For more informationon > > why this is A Bad Idea, and how to do what you *should* do instead, please > > read the FAQ entry "How can I use a variable as a variable name": > > > > perldoc -q 'variable name' > > > > Paul Lalli > > I try to enlarge the variablename of my scalar $name so that i have > later a variable named $name666 or $name999 with the value "Hello". > Yes. This is what I said. You are trying to use a variable (in this case $nr1 or $nr2) as part of a variable name. This is not a good idea. Please read the FAQ I mentioned in my previous reply. If you do not understand something in that FAQ, let us know what you don't understand. Paul Lalli |
Re: enlarge Variablenames
[Please do not top-post]
[Please trim the quoted text to a reasonble amout that is needed for context] Ugur Boss wrote: > I try to enlarge the variablename of my scalar $name so that i have > later a variable named $name666 or $name999 with the value "Hello". This is A Bad Idea. Please see 'perldoc -q "variable name"' why and what to do instead. jue |
Re: enlarge Variablenames
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message news:4gDzc.46771$TR1.20338@nwrddc01.gnilink.net... > [Please do not top-post] > [Please trim the quoted text to a reasonble amout that is needed for > context] Also, aren't these top posts? ;-) Not I whole heartedly agree with Jügen, trim, trim, trim! Way too much excess is quoted. |
Re: enlarge Variablenames
"Andrew DeFaria" <Andrew@DeFaria.com> wrote in message
news:746e9$40cf68b4$c09cfc9$28691@msgid.meganewsse rvers.com... > > "Jürgen Exner" <jurgenex@hotmail.com> wrote in message > news:4gDzc.46771$TR1.20338@nwrddc01.gnilink.net... > > [Please do not top-post] > > [Please trim the quoted text to a reasonble amout that is needed for > > context] > > Also, aren't these top posts? ;-) not really. these were general comments that did not depend on any quoted text. Jürgen could have stopped there but decided to also reply to the top-poster, and did that properly quoted, of course gnari |
Re: enlarge Variablenames
Ugur Boss wrote:
> my Problem ist following: > > $nr1 = 1; > $nr2 = 2; > > $name.$nr = "Hello"; my %name; # Use a hash $name{666} = "Number of the beast"; $name{foo} = "bar"; $name{$nr1} = "one"; $name{$nr2} = "two"; |
| All times are GMT. The time now is 02:01 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.