Hallo, Am Mit, 04 Jul 2007, Dr. Jürgen Vollmer schrieb:
Am Mittwoch, 4. Juli 2007 schrieb Hannes Vogelmann:
Am Tag 07-07-04 zur Zeit 15:14:32 schrieb Dr. Jürgen Vollmer: [..]
my ${a_$i} = $n;
hmm, so geht das leider nicht. Ich bekomme dann eine Fehlermeldung:
Can't declare scalar dereference in my at ./test.pl line 6, near "} ="
sorry, ich meinte natürlich: ${"a_$i"}
$ perl -Mstrict -we 'for my $n (0..10){ ${"a_$n"} = $n; }' Can't use string ("a_0") as a SCALAR ref while "strict refs" in use at -e line 1. Hannes, du solltest ein Array oder, je nach Anwendung, auch ein Hash verwenden... ==== perldoc -q "variable name" ==== How can I use a variable as a variable name? [..] This works sometimes, but it is a very bad idea for two reasons. The first reason is that this technique only works on global variables. [..] The other reason why using a variable to hold the name of another variable is a bad idea is that the question often stems from a lack of understanding of Perl data structures, particularly hashes. ==== -dnh -- "I think there is a world market for maybe five computers." -- Thomas Watson, chairman of IBM, 1943. -- Um die Liste abzubestellen, schicken Sie eine Mail an: opensuse-de+unsubscribe@opensuse.org Um eine Liste aller verfuegbaren Kommandos zu bekommen, schicken Sie eine Mail an: opensuse-de+help@opensuse.org