Roger wrote:
>
Something's missing here:
use strict;
use warnings;
> @list = ("w","d","e","e","d","r","f","e","d",
> "c","v","g","h","t","y","h","g","t","h","y","D","P ");
Better written as
my @list = qw/w d e e d r f e d c v g h t y h g t h y D P/;
> while( @list ) # just debugging here
> {
A while loop like that makes an endless loop. Take it away.
> @end = @list[16..19];
> splice (@list,16,17, "Z", "X"); # after this 18..21 are undef
You should study the documentation for splice():
perldoc -f splice
One thing you'll notice is that the third argument is the number of
elements to be removed. Your use of 17 indicates that you have
misunderstood that.
> splice(@list ,18,1, @end);
The push() function would be more suitable here.
perldoc -f push
This is an easier way to accomplish the exchange of elements:
my @end = splice @list, 16;
push @list, 'Z', 'X', @end[0..3];
> ($Fld1) = "|" . join "|", @list ;
> ($Fld1) .= "|";
> print $Fld1;
No need to concatenate the parts into a scalar variable.
print '|', (join '|', @list), "|\n";
> #It might be a hash would be a better choice, but my
> #'expertise' does not yet reach to that data type
Can't see how a hash would be better.
--
Gunnar Hjalmarsson
Email:
http://www.gunnar.cc/cgi-bin/contact.pl