Front page | perl.fwp |
Postings from February 2005
Re: "Secret" operators
Thread Previous
From:
philippe.bruhat
Date:
February 1, 2005 09:14
Subject:
Re: "Secret" operators
Message ID:
20050201171253.GA7000@localhost.localdomain
Le mardi 01 février 2005 à 18:57, Vladi Belperchinov-Shabanski écrivait:
> On Tue, 1 Feb 2005 15:57:33 +0100
> philippe.bruhat@free.fr (Philippe 'BooK' Bruhat) wrote:
>
> >
> > There's also @{[]} but I don't know f it has a name.
> >
> > Usage: print "splatt @{[ ... ]} pow"
> > where ... is any valid expression, and the result list is join()ed with $"
> > (space).
>
> [] construct reference to anonymous array, @{} dereferences the array ref.
> finally the array is interpolated inside string.
>
> it is equal to:
>
> @a = ( 1, 2, 3 );
> print "splatt @a pow";
>
> the only use is to force array context inside string:
>
> %a = ( 1, 2, 3 );
> print "splatt @{[%a]} pow";
>
> but don't think it is usefull (except obfuscation bonus:))
I won't defend its usefulness (we're here for fun), but sometimes you
don't want to type
use Acme::MetaSyntactic 'batman';
print "splatt " . join( " ", metaname(3) ) . " pow";
when
use Acme::MetaSyntactic 'batman';
print "splatt @{[metaname 3]} pow";
will do.
--
Philippe "BooK" Bruhat
A reputation is only as good as the truth beneath it, if any.
(Moral from Groo The Wanderer #91 (Epic))
Thread Previous