#!/usr/bin/perl use strict; use warnings; my @first = qw(Can unlock secret); my @second = qw(you the code?); my @mixed = interleave_words( scalar(@first), \@first, \@second ); print "Result: @mixed\n"; sub interleave_words { my ($count, $first, $second) = @_; my @results; die unless $#$first == $#$second; return map { $$first[$_], $$second[$_] } 0..$count-1; }