Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Breaking The Rules II

by Limbic~Region (Chancellor)
on Jul 02, 2007 at 13:48 UTC ( #624445=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download

  1. or download this
    package Math::Expression::Evaluator;
    @ISA    = qw(Exporter);
    'This statement is false';
  2. or download this
    use strict;
    my $parser = new Parse::RecDescent $grammar;
    print Dumper $parser->evaluate('42 - 5 + 1');
    # Sees the result as 42 - (5 + 1)
  3. or download this
    use strict;
    my $parser = new Parse::RecDescent $grammar;
    print Dumper $parser->evaluate('42 - 5 + 1');
  4. or download this
    use strict;
    my $parser = Parse::RecDescent->new($grammar) or die("Bad grammar\n");
    my $answer = $parser->evaluate('11 - (4 + 4)^3 * sqrt(5 * (6 - 1)) + a
    print defined $answer ? $answer : 'Invalid expression';
  5. or download this
    use strict;
    my $tree = $parser->build('11 - 6 + 4');
    my $eval = eval_node($tree);
    print "$eval\n";
  6. or download this
    use strict;
        my $self = shift @_;
        $self->YYData->{INPUT} = $_[0];
  7. or download this
    use strict;
    $parser->advance($str) for 1..6;
    my ($tree) = $parser->matches_all($str, 'input');
    print Dumper($tree);

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://624445]
Approved by Old_Gray_Bear
Front-paged by Old_Gray_Bear
[Corion]: Meh. I get the feeling I should post a call-to-action for people to test their modules with the upcoming 5.26 (or 5.25.latest), as it seems that the smoke testers don't really weed out modules that fail without . in @INC
[Corion]: But without instructions on how to easily test things yourself, I don't think such a call to arms is helpful
[Corion]: (this post on / p5p makes it seem to me that smoke testers seem to have a blind spot there)
[Corion]: Hmmm. Maybe setting $ENV{PERL5LIB}=" some path without dot"; perl Makefile.PL; make test already is enough to locally test your module...
[Corion]: Meh, no, will need a BEGIN hook...
[Corion]: ... and PERL5OPT does not like -e in it :-(

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2017-03-27 08:04 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (317 votes). Check out past polls.