You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
463 B
Perl

#!/usr/bin/perl
use warnings;
use strict;
my @array1 = ( 1 .. 8 );
my @array2 = ( 'a' .. 'e' );
my @mixed = arrayMixer( \@array1, \@array2 );
print( "@mixed\n" );
sub arrayMixer
{
my @firstArray = @{ $_[ 0 ] };
my @secondArray = @{ $_[ 1 ] };
my ( $first, $second, @array );
while ( ( $first = shift( @firstArray ) ) && ( $second = shift( @secondArray ) ) ) {
push( @array, $first, $second );
}
return @array;
}