#!/usr/bin/perl -w use strict; # here we have an irregular sized 2D array my @array = ( [1],[2,2],[3,3,3],[4,4,4,4] ); my $all ='42'; # this sets all elements to $all for (@array) { @$_ = ($all) x @$_; } # this also sets all elements to $all # map is just the loop above in short form map{ @$_ = ($all) x @$_ }@array; # this prints the entire structure for (@array) { for (@$_) { print "-",$_; } print"\n"; } #### map{ push @list, @$_ }@array; print "@list";