LvalueSection: User Contributed Perl Documentation (3)Updated: 2001-07-07 |
LvalueSection: User Contributed Perl Documentation (3)Updated: 2001-07-07 |
$a->slice(',(0)') .= 1;
instead of the clumsy
(my $tmp = $a->slice(',(0)')) .= 1;
This will only work if your perl supports lvalue subroutines (i.e. versions >= v5.6.0). Note that lvalue subroutines are currently regarded experimental.
use PDL::Lvalue; # automatically done with all PDL loaders
print "slice is an lvalue sub" if PDL::Lvalue->subs('slice');
returns the list of PDL lvalue subs if no routine name is given, e.g.
@lvfuncs = PDL::Lvalue->subs;
It can be used in scalar context to find out if your PDL has lvalue subs:
print 'has lvalue subs' if PDL::Lvalue->subs;