Philip Potter wrote:
> 2009/12/11 Steve Bertrand <st...@ibctech.ca>:
>> Rafa? Pocztarski wrote:
>>> There is no := operator in Perl 5. In Perl 6 := is a run-time binding 
>>> operator:
>>>
>>> $x = 1;
>>> $y := $x;
>>> $y = 2;
>>>
>>> Now both $x ==2 and $y == 2
>>> In Perl 5 you use typeglob assignment to achieve the same thing:
>>>
>>> $x = 1;
>>> *y = \$x;
>>> $y = 2;
>> Does this mean "no strict 'refs'" will no longer be needed in cases
>> where the symbol table must be manipulated manually?
> 
> It isn't needed right now!
> 
> p...@tui:~/tmp$ cat bar.pl
> use strict;
> use warnings;
> 
> our ($x, $y) = (0,1);
> 
> *y = \$x;
> 
> $y = 3;
> print "\$x = $x and \$y = $y\n";
> p...@tui:~/tmp$ perl bar.pl
> $x = 3 and $y = 3
> 
> strict 'refs' only prevents messing around with symbolic references.
> These are hard references.

D'oh! Of course :)

Thanks for the clarification.

I was thinking for the odd time I do this:

for my $member (@constants) {
        
        no strict 'refs';
        
        *{$member} = sub {
                my $self = shift;
                $self->{config}{$member} = shift if @_;                 

                return $self->{config}{$member};
        }
}

...but completely forgot about the 'symbolic' part.

Steve

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to