En réponse à Stephen Turner <[EMAIL PROTECTED]>:

> On Wed, 30 Jan 2002 [EMAIL PROTECTED] wrote:
> > 
> > Bingo! The only thing left was to figure out how to convert that
> > into a string for eval. I could see no better way than the
> > standard @{[]} notation
> 
> Would someone be kind enough to get me up to speed on @{[]} ?

"@a" turns the array @a in a string, where each elements of @a are
separated by $".

This is more or less equivalent to  join$",@a

[ ] returns an array reference.

So when you write "@{[1..3]}", you dereference an array reference, and turn it 
into a string, with elements join()ed by $".

"@{[1..3]}" eq "1 2 3"; # $" equals ' ' by default

A possibly shorter way to join() array elements :
 $a=join a,@a
vs.
 $"=a;$a="@a"

And it can actually be shorter, sometimes:
 print join a,@a
vs.
 $"=a;print"@a"

It may not be shorter every single time, but you get to learn yet another
special variable. :-)


Another nice thing about this use of glob, is that you can use it to get
all permutations of something in a very short manner :

 $"=",";
 @a=1..3; @b=4..6;
 print join' ',glob("{@a}{@b}");

Result:
14 15 16 24 25 26 34 35 36

All of this without a single loop construct! :-)

-- 
 Philippe BRUHAT - BooK

 When you run from your problem, you make it that much harder for good
 fortune to catch you, as well.     (Moral from Groo The Wanderer #14 (Epic))

Reply via email to