#!/usr/bin/perl use warnings; use strict; print 'Enter the number of elements: '; my $n = <>; # Read the input. chomp $n; # Remove the newline. print "Enter $n numbers.\n"; my @a; for (1 .. $n) { push @a, scalar <>; # Push numbers to the array. } chomp @a; # Remove the newlines. print join (' ', 'The even numbers are:', grep $_ % 2, @a), # grep filters the numbers = 1 modulo 2 "\n"; print join (' ', 'The odd numbers are:', grep 1 - $_ % 2, @a), "\n";