Dear Monks,
I'm attempting to write an encryption (and matching decryption) program, but it just was not working. No warnings or anything, but it wasn't giving me the correct output. As for the encryption half, I found the section that wasn't working, but I can't figure out why. Anybody think they'll be able to help? I isolated the task and gave an example input.
my @array=(1,2,3,4,5,6,7,8);
my @array2;
my $length = @array;
my $length2 = $length-1;
my $i;
for $i(0..$length2){
push @array2, $array[$i];
$i+=2;
}
for $i(1..$length){
push @array2, $array[$i];
$i+=2;
}
undef @array;
@array=reverse(@array2);
undef @array2;
for $i(1..$length){
push @array2, $array[$i];
$i+=2;
}
for $i(0..$length2){
push @array2, $array[$i];
$i+=2;
}
undef @array;
@array=reverse(@array2);
print @array;
The desired output is "51627384" if that helps.