/usr/share/perl5/Text/PDF/Array.pm is in libtext-pdf-perl 0.29a-3.
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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | package Text::PDF::Array;
use strict;
use vars qw(@ISA);
# no warnings qw(uninitialized);
use Text::PDF::Objind;
@ISA = qw(Text::PDF::Objind);
=head1 NAME
Text::PDF::Array - Corresponds to a PDF array. Inherits from L<PDF::Objind>
=head1 INSTANCE VARIABLES
This object is not an array but an associative array containing the array of
elements. Thus, there are special instance variables for an array object, beginning
with a space
=over
=item var
Contains the actual array of elements
=back
=head1 METHODS
=head2 PDF::Array->new($parent, @vals)
Creates an array with the given storage parent and an optional list of values to
initialise the array with.
=cut
sub new
{
my ($class, @vals) = @_;
my ($self);
$self->{' val'} = [@vals];
$self->{' realised'} = 1;
bless $self, $class;
}
=head2 $a->outobjdeep($fh, $pdf)
Outputs an array as a PDF array to the given filehandle.
=cut
sub outobjdeep
{
my ($self, $fh, $pdf, %opts) = @_;
my ($obj);
$fh->print("[ ");
foreach $obj (@{$self->{' val'}})
{
$obj->outobj($fh, $pdf, %opts);
$fh->print(" ");
}
$fh->print("]");
}
=head2 $a->removeobj($elem)
Removes all occurrences of an element from an array.
=cut
sub removeobj
{
my ($self, $elem) = @_;
$self->{' val'} = [grep($_ ne $elem, @{$self->{' val'}})];
}
=head2 $a->elementsof
Returns a list of all the elements in the array. Notice that this is
not the array itself but the elements in the array.
=cut
sub elementsof
{ wantarray ? @{$_[0]->{' val'}} : scalar @{$_[0]->{' val'}}; }
=head2 $a->add_elements
Appends the given elements to the array. An element is only added if it
is defined.
=cut
sub add_elements
{
my ($self) = shift;
my ($e);
foreach $e (@_)
{ push (@{$self->{' val'}}, $e) if defined $e; }
$self;
}
=head2 $a->val
Returns the value of the array, this is a reference to the actual array
containing the elements.
=cut
sub val
{ $_[0]->{' val'}; }
=head2 $d->copy($inpdf, $res, $unique, $outpdf, %opts)
Copies an object. See Text::PDF::Objind::Copy() for details
=cut
sub copy
{
my ($self, $inpdf, $res, $unique, $outpdf, %opts) = @_;
my ($i, $path);
$res = $self->SUPER::copy($inpdf, $res, $unique, $outpdf, %opts);
$res->{' val'} = [];
$path = delete $opts{'path'};
for ($i = 0; $i < scalar @{$self->{' val'}}; $i++)
{
if (UNIVERSAL::can($self->{'val'}[$i], "is_obj") && !grep {"$path\[$i\]" =~ m|$_|} @{$opts{'clip'}})
{ push (@{$res->{' val'}}, $self->{' val'}[$i]->realise->copy($inpdf, undef, $unique ? $unique + 1 : 0,
$outpdf, %opts, 'path' => "$path\[$i\]")); }
else
{ push (@{$res->{' val'}}, $self->{' val'}[$i]); }
}
$res->{' realised'} = 1;
$res;
}
1;
|