in reply to Pushing Element Multiple Times to Array

push @arry, ( $var ) x $cnt;
or longwinded
push @arry, $var for 0 .. $cnt; push @arry, map { $var } 0 .. $cnt;

Replies are listed 'Best First'.
Re^2: Pushing Element Multiple Times to Array
by CountZero (Bishop) on Feb 13, 2011 at 09:54 UTC
    "Off by one" error in 0 .. $cnt! It should be 1 .. $cnt.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James