http://qs321.pair.com?node_id=1233311

Newbie95 has asked for the wisdom of the Perl Monks concerning the following question:

Hi all. I wanted to know if it's possible to join string inside the 2D array and store it into 1D array. I know if it's 1D array you can store it in the scalar variable but does this work for 2D array? Here is my code:

use warnings; use strict; use Data::Dumper qw(Dumper); my $clk_new; my @clk_new; my @clk = ('ux_prim_clk', 'ux_side_clk', 'ux_xtal_frm_refclk'); my @clk_output = map [ split /_/, $_ ], @clk; print Dumper \@clk_output; for ( my $c= 0; $c<= $#clk_output; $c++) { for ( my $d = 0; $d <= $#{$clk_output[$c]}; $d++ ) { $clk_new = join '_', $clk_output[$c]; print Dumper $clk_new; push @clk_new, $clk_new; } } print Dumper @clk_new;

When i print this, it will give me this output:

$VAR1 = [ [ 'ux', 'prim', 'clk' ], [ 'ux', 'side', 'clk' ], [ 'ux', 'xtal', 'frm', 'refclk' ] ]; $VAR1 = 'ARRAY(0x619920)'; $VAR1 = 'ARRAY(0x619920)'; $VAR1 = 'ARRAY(0x619920)'; $VAR1 = 'ARRAY(0x625700)'; $VAR1 = 'ARRAY(0x625700)'; $VAR1 = 'ARRAY(0x625700)'; $VAR1 = 'ARRAY(0x6929a0)'; $VAR1 = 'ARRAY(0x6929a0)'; $VAR1 = 'ARRAY(0x6929a0)'; $VAR1 = 'ARRAY(0x6929a0)'; $VAR1 = 'ARRAY(0x619920)'; $VAR2 = 'ARRAY(0x619920)'; $VAR3 = 'ARRAY(0x619920)'; $VAR4 = 'ARRAY(0x625700)'; $VAR5 = 'ARRAY(0x625700)'; $VAR6 = 'ARRAY(0x625700)'; $VAR7 = 'ARRAY(0x6929a0)'; $VAR8 = 'ARRAY(0x6929a0)'; $VAR9 = 'ARRAY(0x6929a0)'; $VAR10 = 'ARRAY(0x6929a0)';

I want to store back this array to be like this:

my @clk_new =  ('ux_prim_clk', 'ux_side_clk', 'ux_xtal_frm_refclk');

May I know if my method is wrong? Thank you in advance.