Acme-AlgebraicToRPN
view release on metacpan or search on metacpan
lib/Acme/AlgebraicToRPN.pm view on Meta::CPAN
Acme::AlgebraicToRPN - convert algebraic notation to sane RPN
=head1 VERSION
Version 0.02
=head1 SYNOPSIS
$rpn = Acme::AlgebraicToRPN->new;
@RPN = $rpn->eval($equation);
=head1 DESCRIPTION
Given a string with algebraic notation, convert to RPN, which is
what any crappy dime store calculator needs to do anyway.
Doesn't really process anything, that's up to you. You will get an
array back with all of the variables and operations in RPN format.
So that 3+4 will come back as
lib/Acme/AlgebraicToRPN.pm view on Meta::CPAN
my ($self, $algebraic) = @_;
$algebraic =~ s/\s+//g;
# ensure parens match
my $open = $algebraic =~ tr/(/(/;
my $close = $algebraic =~ tr/)/)/;
return unless $open == $close;
#my $tree = Math::Symbolic->parse_from_string($algebraic);
my $tree;
my $rpn;
eval q(
$tree = $.parser->parse($algebraic);
$rpn = $tree->to_string('prefix');
);
if ($@) {
print STDERR "$.Class - equation didn't parse; did you forget ",
"to add a userFunc?\n";
return undef;
}
t/pod-coverage.t view on Meta::CPAN
use strict;
use warnings;
use Test::More;
# Ensure a recent version of Test::Pod::Coverage
my $min_tpc = 1.08;
eval "use Test::Pod::Coverage $min_tpc";
plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage"
if $@;
# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
# but older versions don't recognize some common documentation styles
my $min_pc = 0.18;
eval "use Pod::Coverage $min_pc";
plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
if $@;
all_pod_coverage_ok();
#!perl -T
use strict;
use warnings;
use Test::More;
# Ensure a recent version of Test::Pod
my $min_tp = 1.22;
eval "use Test::Pod $min_tp";
plan skip_all => "Test::Pod $min_tp required for testing POD" if $@;
all_pod_files_ok();
( run in 1.014 second using v1.01-cache-2.11-cpan-5a3173703d6 )