On Friday, May 17, 2002, at 05:16 , Mark Anderson wrote:
we all agree that this is a 'bad' idea and that timothy has the right solution... now for the troubling bits... >> What's the best way to do this? I've tried >> >> foreach (qw(name age phone)) { >> print ${$_}; >> } >> >> ....but that doesn't seem to work. > > It works for me (using perl 5.6.1), what seems to be the problem? what version of perl 5.6.1 are you using? barring the fact that I had to turn strict off my ($name, $age, $phone) = qw/ drieux InHex cellular/; foreach($name,$age,$phone){ print "\t$_ \n"; } foreach (qw(name age phone)) { if ( ${$_} ) { print " happy Thoughts $_ => ${$_} \n"; } else { print "\tUnhappy, know $_ but not \$\{$_\} \n"; } } generates: drieux InHex cellular Unhappy, know name but not ${name} Unhappy, know age but not ${age} Unhappy, know phone but not ${phone} on the perl v5.6.1 - ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]