Shiping Wang wrote:
> Hi,

Hello,

> I have a big array, I need re-arrange it then put into sub array,
> after that do something on each sub array. I have a problem to
> dynamically give sub array a name. Any help? Maybe I should use
> anonymous array?

It looks like you may need a Hash of Arrays.

> Here is my code:
> 
> use strict;
> use warnings;
> 
> my @big_arr = (
> 0.06,0.04,0.98,0.12,0.02,0.98,0.11,0.25,0.36,0.01,0.01,0.01,0.02,0.01,0.05,0.056,
> 0.046, 0.98, 0.12,
> 0.002,0.06,0.04,0.98,0.12,0.02,0.98,0.11,0.25,0.36,0.01,0.01,0.01,0.02,0.01,0.05,0.056,
> 0.046, 0.98, 0.12,
> 0.002,0.06,0.04,0.98,0.12,0.02,0.98,0.11,0.25,0.36,0.01,0.01,0.01,0.02,0.01,0.05,0.056,
> 0.046);
> 
> for (my $i = 0; $i < 10; $i++){
>     
>     my @q_$i = ($P_array[$i], @P_array[8*$i+10 .. 8*$i+17]);
>         for (@q_$i){
>             print join "\t", @_$i, "\n";
>         }
> }

for my $i ( 0 .. 9 ) {

    my %q = ( $i => [ $P_array[ $i ], @P_array[ 8 * $i + 10 .. 8 * $i + 17 ] ] 
);

    print join( "\t", @{ $q{ $i } } ), "\n";
}




John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to