$character = "0"; #character to print @howmany = ( [4,2,4,2,3,3,1,4], #layout of "0" and " " [1,2,1,2,1,5,1,2,1,2,1,4], [4,2,4,2,3,3,1,4], [1,5,1,5,1,1,1,3,1,4], [1,5,4,2,1,2,1,2,4,1] ); for ( 0 .. $#howmany ) { # loop through @howmany foreach ( @{ $howmany[$_] } ) { # loop through the arrays of @howmany for ( 1 .. $_ ) { # print $character the number of times specified by the item of an array of @howmany print $character; } if ($character =~ /^0$/) { #switch $character from "0" to " " $character = " "; } else { $character = "0"; } } print "\n"; }