/usr/lib/perl5/PDL/Lvalue.pm is in pdl 1:2.007-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | =head1 NAME
PDL::Lvalue - declare PDL lvalue subs
=head1 DESCRIPTION
Declares a subset of PDL functions so that they
can be used as lvalue subs. In particular, this allows
simpler constructs such as
$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.
=head1 SYNOPSIS
use PDL::Lvalue; # automatically done with all PDL loaders
=head1 FUNCTIONS
=cut
package PDL::Lvalue;
# list of functions that can be used as lvalue subs
# extend as necessary
my @funcs = qw/ clump diagonal dice dice_axis dummy flat
index index2d indexND indexNDb mslice mv
nslice nslice_if_pdl nnslice polyfillv px range
rangeb reshape sever slice where whereND xchg /;
my $prots = join "\n", map {"use attributes 'PDL', \\&PDL::$_, 'lvalue';"}
@funcs;
=head2 subs
=for ref
test if routine is a known PDL lvalue sub
=for example
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;
=cut
sub subs {
my ($type,$func) = @_;
if (defined $func) {
$func =~ s/^.*:://;
return ($^V and $^V >= 5.006007) && scalar grep {$_ eq $func} @funcs;
} else {
return ($^V and $^V >= 5.006007) ? @funcs : ();
}
}
# print "defining lvalue subs:\n$prots\n";
eval << "EOV" if ($^V and $^V >= 5.006007);
{ package PDL;
no warnings qw(misc);
$prots
}
EOV
=head1 AUTHOR
Copyright (C) 2001 Christian Soeller (c.soeller@auckland.ac.nz). All
rights reserved. There is no warranty. You are allowed to redistribute
this software / documentation under certain conditions. For details,
see the file COPYING in the PDL distribution. If this file is
separated from the PDL distribution, the copyright notice should be
included in the file.
=cut
1;
|