On Friday, June 7, 2002, at 06:05 , Michael Fowler wrote:

> On Fri, Jun 07, 2002 at 05:30:17PM -0700, Bryan R Harris wrote:
>>
>> Quick question:
>>
>> When exactly are {} braces required?  I notice when following references,
>> $ { $var } and $$var both work identically.  Do you ever actually need
>> them?
>
> I'm assuming you meant in the context of dereferencing only.  Braces aren'
> t
> really required, unless you want Perl to do what you want it to.  :)
>
> The braces serve to disambiguate what you're dereferencing.

the general rule of thumb seems to be:

        if you are not sure which you meant
                then curl them up.

you can actually do

        ${varname}

so that when you do

        print "${varname}1\n";

one disambiguates that it is the stuff in $varname rather
than the stuff in $varname1 ....

remember the recent fumble of

        @{$hash{$key}}

since someone had put in

        $hash{$key} = [ @val ];

and one really wanted to pull out the correct 'array' and not
that annoying ARRAY{<someHex>}

Bryan you may want to peek at:

        http://www.wetware.com/drieux/pbl/perlTrick/HashGames.txt

since I think perl like:

        @T_MODULES{@{$T_MODULES{N}}} = ([qw(A B C D E F)]) x 3;

may be about as densely packed as one would want to do without
thinking about restructuring one's core data model.

ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to