/usr/share/perl5/Petal/Utils/Limit.pm is in libpetal-utils-perl 0.06-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 | package Petal::Utils::Limit;
use strict;
use warnings::register;
use Carp;
use base qw( Petal::Utils::Base );
use constant name => 'limit';
use constant aliases => qw();
our $VERSION = ((require Petal::Utils), $Petal::Utils::VERSION)[1];
our $REVISION = (split(/ /, ' $Revision: 1.2 $ '))[2];
sub process {
my $class = shift;
my $hash = shift;
my $args = shift || confess( "'limit' expects 2 variables (got nothing)!" );
my @args = $class->split_args( $args );
my $key = $args[0] || confess( "1st arg to 'limit' should be an array (got nothing)!" );
my $count = $args[1] || confess( "2nd arg to 'limit' should be a variable (got nothing)!" );
my $arrayref = $hash->fetch($key);
$count--;
# trim $count to max size of array
$count = $#$arrayref if $#$arrayref < $count;
return [] if $count < 0;
return [@{$arrayref}[0 .. $count]];
}
1;
__END__
Description: Limit elements returned from an array
Basic Usage:
limit:<list> <count>
list - a list
count - an integer value, if greater than the total items in the list,
return complete list
Example:
<div class="content" tal:repeat="fact limit:facts 2">
<p tal:content="fact/fld_fact">Fact</p>
</div>
|