sub centerlines { my $width = shift; print map { ' ' x int($width/2 - length($_)/2) . $_ } @_; } centerlines($width, 'These', 'lines', 'are', 'centered');