What are Even Numbers? | Maths Explanation for Perl Kids
                    
                        Hello pupils, what are even numbers?
                        Answer:
                        Even numbers are numbers that are divisible by 2.
                        
                        They include:
                    
                        Considering how simple and straight-forward even numbers are, writing a Perl code for even numbers 
                        serves as a great way to introduce our Mathematics educational activities for young learners.
                        Well then, let's see how we can write a programming code to make our computer
                        list a set of even numbers in the Perl language, between a given range of values.
                        Bear in mind, we use only a loop and a simple conditional statement for the Perl code.
                    
                        Create a new Perl Class File;
                        call it Arithmetic.pl.
                        Create a new Perl Module File;
                        call it evenNumbers.pm.
                        
                        Type out the adjoining Perl code that list even numbers.
                    
How to run Perl Codes
                        Run the code from the cmd shell with the command:
                        cd ~/Documents/usingMaths  -- to navigate to the folder where 
                        you saved your files;
                        perl Arithmetic.pl
                    
So! Perl Fun Practice Exercise - List Even Numbers
As a fun practice exercise, feel free to try out your own boundary values, and see how the Perl code lists the even numbers between those boundary values.
Perl Code for Even Numbers - Module File.
BEGIN {
require Exporter;
# for the sake of standard
our $VERSION = 2016.12;
# Inherit from exporter to export functions and variables
our @ISA = qw(Exporter);
# Functions and variables to be exported by default
our @EXPORT_OK = qw(prepResult);
}
use warnings;
use strict;
my ($start, $stop);
my @result;
# simulate an object construct
# takes two arguments -- besides its name;
# start and stop values for the range
sub new {
my $this = shift;
my $parameters = {@_};
bless $parameters, $this;
$this->_init(@_);
return $this;
}
# Simulate a constructor
sub _init {
my $self = shift;
($start, $stop) = @_;
}
# Returns an array reference of the desired set of even numbers
sub prepResult {
# Loop from start to stop and rip out even numbers;
until ($start > $stop) {
if (($start % 2) == 0) { # modulo(%) is explained later
push @result, $start;
}
$start = $start + 1; # increase start by 1
}
return \@result;
}
1;
Perl Code for Even Numbers - Main class.
use strict;
use warnings;
use EVENNUMBERS;
# Useful variables
my ($lower_boundary, $upper_boundary, $answer);
# Use the even number module/class
$lower_boundary = 1;
$upper_boundary = 100;
my $even_list = EVENNUMBERS->new($lower_boundary, $upper_boundary);
$answer = $even_list->prepResult();
print "Even numbers between $lower_boundary and $upper_boundary are:\n@{$answer}\n";
print "\n\n";