develooper Front page | | Postings from July 2002

Re: more minigolf

Thread Previous | Thread Next
July 11, 2002 17:57
Re: more minigolf
Message ID:
En op 12 juli 2002 sprak FatPhil:
> print"@{[$w=1,map$w*=$_/--$n,-pop..-2]}\n")
> Please - noone feed me any more information - it might trip
> the balance the other way again! :-| 
> Truly not of this earth...

Though Ton is not of this earth, the @{[...]} idiom is.
(I think Larry plans to clean it up for Perl 6, however).

I knew about it long before I swung my first club.
I learnt about by reading the Camel (p. 259, "Other Tricks
You Can Do With Hard References", Chapter 8) and from
"Effective Perl Programming", Item 58 "Use @{[...]} or
a tied hash to evaluate expressions inside strings".
Curiously, Joseph N. Hall (who is a keen real golfer)
uses a golf example to explain it on p. 240:
  print "I'm @{[$golfer->name]}\n";  I'm Tiger Woods

Here is another reference to where this trick was used
in a golf game:


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About