in reply to understand and prevent 'Out of memory!' during sub recursion

My usual rule for recursion is to check if we are done first, then recurse.

For this problem, it avoids "Use of uninitialized value in print..." which isn't checked for :)

#!/usr/bin/perl # http://perlmonks.org/?node_id=1203005 use strict; use warnings; inter([1],[1,2],[1,2,3],[1,2,3,4,5]); sub inter { @_ && inter( grep { @$_ && print shift @$_ } @_ ) }