#!/usr/bin/perl use strict; use warnings; # Effect a "join" with ", " local $"=', ';#" # Use the baby cart so we can call even / odd within quotes to exploit $" print "@{[even(1,2,3,4)]} are even\n while @{[odd(1,2,3,4)]} are odd\n"; exit; # Note the use of prototypes so we can pass the list and the desired remainder without flattening sub EvenOrOdd (\@$) { my ($numbers,$remainder)=@_; return grep { $_ % 2 == $remainder } @$numbers; }; sub even { EvenOrOdd(@_,0); }; sub odd { EvenOrOdd(@_,1); };