Hi Gabor,

>
> perldl> $a = zeroes(3,3);
>
> perldl> $a(1,1) = 1


Here you want '.='. So:

   perldl> $a(1,1) .= 1

works as you would expect '=' to have done. This is a limitation of  
Perl syntax and was the cause for quite a bit of head scratching at an  
early stage of PDL development as it was not possible to use a  
subroutine as an lvalue. This is no longer the case but I don't think  
this discussion has been reopened(?). Thus the '.=' was designed as  
the PDL assignment operator.

Unfortunately '=' would be correct Perl syntax so I don't think it is  
easy to catch the bad uses of it.

The major advantage of this is that you can operate on small bits of  
your data without making copies:

    perldl> $x = sequence(100, 100)
    perldl> p $x((25),(30))
    3025
    perldl> $window = $x(25:30,30:45)
    perldl> $window .= sqrt($window)
    perldl> p $x((25),(30))
    55

This is possibly too subtle at times though :)

                Cheers,
                Jarle.


_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to