Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Breaking The Rules II

by Limbic~Region (Chancellor)
on Jul 02, 2007 at 13:48 UTC ( [id://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);
    ...
        return;
    }
    'This statement is false';
    
  2. or download this
    #!/usr/bin/perl
    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
    #!/usr/bin/perl
    use strict;
    ...
    };
    my $parser = new Parse::RecDescent $grammar;
    print Dumper $parser->evaluate('42 - 5 + 1');
    
  4. or download this
    #!/usr/bin/perl
    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
    +bs(-3)');
    print defined $answer ? $answer : 'Invalid expression';
    
  5. or download this
    #!/usr/bin/perl
    use strict;
    ...
    my $tree = $parser->build('11 - 6 + 4');
    my $eval = eval_node($tree);
    print "$eval\n";
    
  6. or download this
    #!/usr/bin/perl
    use strict;
    ...
        my $self = shift @_;
        $self->YYData->{INPUT} = $_[0];
    }
    
  7. or download this
    #!/usr/bin/perl
    use strict;
    ...
    $parser->advance($str) for 1..6;
    my ($tree) = $parser->matches_all($str, 'input');
    print Dumper($tree);
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://624445]
Approved by Old_Gray_Bear
Front-paged by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (1)
As of 2024-04-24 15:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found