Acme-Pythonic-Functions
view release on metacpan or search on metacpan
lib/Acme/Pythonic/Functions.pm view on Meta::CPAN
sub lstrip2 {
checkArgs(2, @_);
my ($a, $b) = @_;
if($a !~ /^\Q$b\E/) {
return $a;
}
if (length($b) > length($a)) {
return $a;
}
return substr($a, length($b));
}
sub replace {
my $nrargs = @_;
if($nrargs < 3 || $nrargs > 4) {
croak "Error: Function 'replace()' takes either 3 or 4 arguments ($nrargs given),";
}
lib/Acme/Pythonic/Functions.pm view on Meta::CPAN
sub rstrip2 {
checkArgs(2, @_);
my ($a, $b) = @_;
if($a !~ /\Q$b\E$/) {
return $a;
}
if (length($b) > length($a)) {
return $a;
}
return substr($a, 0, length($a) - length($b));
}
sub startswith {
checkArgs(2, @_);
if ($_[0] =~ /^\Q$_[1]\E/) {
return 1;
}
lib/Acme/Pythonic/Functions.pm view on Meta::CPAN
if ($mode ne "s" && $mode ne "l" && $mode ne "h") {
croak "Error: Last argument to 'len()' must be 's', 'l' or 'h',";
}
if ($mode eq "s") {
if ($lenarg != 2) {
croak "Error: 'len()' in mode 's' takes exactly 2 arguments ($lenarg given),";
}
return length($_[0]);
}
if ($mode eq "l") {
return $lenarg - 1;
}
# Only mode 'h' is left by now.
if (! $lenarg % 2) {
croak "Error: Unsuitable arguments to 'isin()' in 'h'-mode,";
( run in 0.900 second using v1.01-cache-2.11-cpan-65fba6d93b7 )