Parse-RPN
view release on metacpan or search on metacpan
lib/Parse/RPN.pm view on Meta::CPAN
=head2 a LCFIRST
return 'a' with the first letter in lowercase
=cut
$dict{LCFIRST} = sub {
my $work1 = shift;
my $a = pop @{ $work1 };
my @ret;
push @ret, ( lcfirst $a );
return \@ret, 1, 0;
};
=head2 a R1 R2 K V SPLIT2
split a with the REGEX R1
each result are splitted with the REGEX R2
the result are stored in the variable k and v
# .1.3.6.1.2.1.25.3.3.1.2.768 | 48 # .1.3.6.1.2.1.25.3.3.1.2.769 | 38 # .1.3.6.1.2.1.25.3.3.1.2.771 | 42 # .1.3.6.1.2.1.25.3.3.1.2.770 | 58 #,\s?#\s?,\s\|\s,a,b,SPLIT2
return a with .1.3.6.1.2.1.25.3.3.1.2.768,.1.3.6.1.2.1.25.3.3.1.2.769,.1.3.6.1.2.1.25.3.3.1.2.771,.1.3.6.1.2.1.25.3.3.1.2.770
and b with 48,38,42,58
!!! becare, if you need to use : as a regex, you need to backslash to prevent overlap with new dictionary entry
SPLIT return the matched value WITHOUT the empty string of the beginning
=cut
$dict{SPLIT2} = sub {
my $work1 = shift;
my $v2 = pop @{ $work1 };
my $v1 = pop @{ $work1 };
my $r2 = pop @{ $work1 };
my $r1 = pop @{ $work1 };
my $b = pop @{ $work1 };
my @T1;
my @T2;
foreach my $i ( split /$r1/, $b )
{
next unless ( $i );
my ( $k, $v ) = split /$r2/, $i, 2;
if ( $k )
{
push @T1, $k;
push @T2, $v;
}
}
$var{ $v1 } = \@T1;
$var{ $v2 } = \@T2;
my @ret;
return \@ret, 5, 0;
};
=head2 a b SPLIT
return all splitted item of 'a' by the separator 'b'
'b' is a REGEX
!!! becare, if you need to use : as a regex, you need to backslash to prevent overlap with new dictionary entry
!!! if the split match on the beginning of string,
SPLIT return the matched value WITHOUT the empty string of the beginning
=cut
$dict{SPLIT} = sub {
my $work1 = shift;
my $a = pop @{ $work1 };
my $b = pop @{ $work1 };
my @r = grep /[^(^$)]/, split /$a/, $b;
my @ret;
push @ret, @r;
return \@ret, 2, 0;
};
=head2 a b SPLITI
return all splitted item of 'a' by the separator 'b'
'b' is a REGEX case insensitive
!!! becare, if you need to use : as a regex, you need to backslash to prevent overlap with new dictionary entry
!!! if the split match on the beginning of string,
SPLIT return the matched value WITHOUT the empty string of the beginning
=cut
$dict{SPLITI} = sub {
my $work1 = shift;
my $a = pop @{ $work1 };
my $b = pop @{ $work1 };
my @r = grep /[^(^$)]/, split /$a/i, $b;
my @ret;
push @ret, @r;
return \@ret, 2, 0;
};
=head2 a b PAT
return one or more occurance of 'b' in 'a'
'b' is a REGEX
!!! becare, if you need to use : as a regex, you need to backslash to prevent overlap with new dictionary entry
=cut
$dict{PAT} = sub {
my $work1 = shift;
my $a = pop @{ $work1 };
my $b = pop @{ $work1 };
my @r = ( $b =~ m/\Q$a\E/g );
my @ret;
push @ret, @r;
return \@ret, 2, 0;
};
=head2 a b PATI
return one or more occurance of 'b' in 'a'
'b' is a REGEX case insensitive
!!! becare, if you need to use : as a regex, you need to backslash to prevent overlap with new dictionary entry
=cut
$dict{PATI} = sub {
my $work1 = shift;
my $a = pop @{ $work1 };
my $b = pop @{ $work1 };
my @r = ( $b =~ m/$a/ig );
my @ret;
push @ret, @r;
return \@ret, 2, 0;
};
=head2 a b TPAT
test if the pattern 'b' is in 'a'
'b' is a REGEX
!!! becare, if you need to use : as a regex, you need to backslash to prevent overlap with new dictionary entry
=cut
$dict{TPAT} = sub {
my $work1 = shift;
( run in 0.707 second using v1.01-cache-2.11-cpan-71847e10f99 )