From: "Chas Owens" <[EMAIL PROTECTED]>
> On 3/26/07, Jochen Jansen <[EMAIL PROTECTED]> wrote:
> > Hi all,
> > I will get the content of an array via a variable in the name of the array.
> > Is it possibel to join the array in a way as I wrote?
> > I know that my example doesn't work
> > Has anybody a solution for me?
> > Thanks a lot
> > Jo
> >
> > @M1= (a,b);
> > @M2= (e,f);
> > $count = 1;
> > until ( $count > 2 ){
> > print @M$count ;
> > $count++;
> > }
>
> Short answer: you don't, you use an AoA (array of arrays)
> Medium answer: it looks like this:
>
> my @M = (
> ['a', 'b'], #create an anonymous array reference
> ['e', 'f'], #ditto
> );
>
> for my $subarray (@M) {
> print @$subarray;
> }
>
>
> Long answer: You can do it and there are several ways, but none of
> them are safe or good so you shouldn't. If you are foolish enough to
> wish to do it anyway or are trying to create obfuscated code (which is
> also foolish, but fun) take a look at the eval function.
eval"" is an overkill. Symbolic references would be enough. Anyway
Jochen please read
"Why it's stupid to `use a variable as a variable name'" at
http://www.plover.com/~mjd/perl/varvarname.html
Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/