in reply to Re^5: Using Splice with Two Arrays within a loop
in thread Using Splice with Two Arrays within a loop
Thanks for the response however as I mentioned I am new to this so where would I add the code you gave in the following script:
Again many thanks#!/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 = shift; my @results = splice @_, $count; foreach my $index ( 0 .. $count-1 ) { splice @results, 2*$index, 0, shift; } return @results; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^7: Using Splice with Two Arrays within a loop
by AnomalousMonk (Archbishop) on Jun 10, 2013 at 22:25 UTC | |
Re^7: Using Splice with Two Arrays within a loop
by hdb (Monsignor) on Jun 11, 2013 at 07:22 UTC | |
by gponcho (Initiate) on Jun 11, 2013 at 12:18 UTC | |
Re^7: Using Splice with Two Arrays within a loop
by hdb (Monsignor) on Jun 10, 2013 at 21:09 UTC |
In Section
Seekers of Perl Wisdom