/usr/share/perl5/Petal/Utils/Decode.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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | package Petal::Utils::Decode;
use strict;
use warnings::register;
use Carp;
use base qw( Petal::Utils::Base );
use constant name => 'decode';
use constant aliases => qw();
our $VERSION = ((require Petal::Utils), $Petal::Utils::VERSION)[1];
our $REVISION = (split(/ /, ' $Revision: 1.3 $ '))[2];
sub process {
my $class = shift;
my $hash = shift;
my $args = shift || confess( "'decode' expects at least 1 variable (got nothing)!" );
my @tokens = $class->split_args( $args );
my $tvar = $class->fetch_arg($hash, shift @tokens);
use Data::Dumper;
while(@tokens) {
my $a = $class->fetch_arg($hash, shift @tokens);
my $b = $class->fetch_arg($hash, shift @tokens);
return $a unless defined($b);
return $b if ($tvar =~ /$a/);
}
}
1;
__END__
Description: The decode function has the functionality of an IF-THEN-ELSE
statement. A case-sensitive regex comparison is performed.
Basic Usage:
decode: expression search result [search result]... [default]
expression is the value to compare.
search is the value that is compared against expression.
result is the value returned, if expression is equal to search.
default is optional. If no matches are found, the decode will return
default. If default is omitted, then the decode statement will return
null (if no matches are found).
All text strings must be enclosed in single quotes.
Example:
If $str = dog,
<p petal:content="decode:$str 'dog'">string</p> # true
<p petal:content="decode:$str 'dog' 100">string</p> # false
<p petal:content="decode:$str 'dog' 'Barker'">string</p> # false
See also:
http://www.techonthenet.com/oracle/functions/decode.htm
Test template t/data/25__decode.html for more examples of use.
|