since you're accessing a global variable in a subroutine, @a will be appended to each time. you need to create a lexical variable, and return it from the subroutine. something like:
sub separate_data { my( @important_data )= @_; my @important_results= split / /, @important_data; return @important_results; } ## call it like my @answer= separate_data( $data[$a] ); ## or in a loop as: for my $a ( 0..10 ) { my @answer= separate_data( $data[$a] ); }
~Particle *accelerates*
In reply to Re: incrementing array name
by particle
in thread incrementing array name
by Lhamo_rin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |