Main Sample

In this section, we combine the knowledge that we provided throughout this chapter. We present the full example program, which you should easily understand. We use the Console class, since we want you to feel comfortable when combining .NET types with Core Perl statements and expressions.

Our sample performs calculations of binary operations (+, –, *, /). It gets as an input an expression (x op y) where x and y are integer positive numbers and op is one of the four operators mentioned above. Our .NET program validates the input using Perl regular expressions (!) and then evaluates the expression. To test the following code, refer to the MainSample\BinOper folder.

 # # BinOper.pl # use namespace "System"; use PerlNET qw(AUTOCALL); ...

Get Programming PERL in the .NET Environment now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.