Help for this page

Select Code to Download


  1. or download this
    #Returns a copy of the input padded to size specified by pad_size with
    + value pad_value.
    #If pad_size is positive then the array is padded on the right, if it'
    +s negative then on the left.
    ...
            return @array;
        }#else
    }#array_pad
    
  2. or download this
    sub p{my($i,$z,@f)=@_;abs$i>@f&&$i<0?@f=(($z) x abs($i+@f),@f):(@f[@f.
    +.$i-1]=($z)x($i-@f));@f}
    
  3. or download this
    use Test::More tests => 4;
    
    ...
    is_deeply([p(-3, 'x', @x)], [ @x ]);
    is_deeply([p( 7, 'x', @x)], [ @x, 'x', 'x' ]);
    is_deeply([p(-7, 'x', @x)], [ 'x', 'x', @x ]);