[Wellington-pm] Strange (for me) notation

Sam Vilain sam at vilain.net
Tue Jul 21 23:43:13 PDT 2009


Chris Eade top-posted:
> Thanks for the info everyone :-)
>
> On Wed, Jul 22, 2009 at 3:05 PM, Olly Betts<olly at survex.com> wrote:
>   
>> On Wed, Jul 22, 2009 at 10:19:55AM +1000, Daniel Pittman wrote:
>>     
>>> ] perl -MO=Deparse example.pl
>>> sub LATEST_D_ACROSS_PRODUCTS () { 'P' }
>>> use constant ('LATEST_D_ACROSS_PRODUCTS', 'P');
>>> $$ib{'reg'}{@{['P'];}} = $ed;
>>> $$ib{'reg'}{'P'} = $ed;
>>> $$ib{'reg'}{&LATEST_D_ACROSS_PRODUCTS} = $ed;
>>> $$ib{'reg'}{'LATEST_D_ACROSS_PRODUCTS'} = $ed;
>>>       
>> Neat, thanks for the tip.
>>
>> Note that this also works as intended, and the constant gets substituted:
>>
>> $ib->{reg}->{(LATEST_D_ACROSS_PRODUCTS)} = $ed;
>>
>> This seems clearer too (constants being subroutines feels like an
>> implementation detail to me).
>>     

But surely you want to know another way, using scalar:
$ib->{reg}{scalar LATEST_D_ACROSS_PRODUCTS}

Sam.


More information about the Wellington-pm mailing list