Created
November 20, 2013 17:08
-
-
Save AndrewRussellHayes/7566936 to your computer and use it in GitHub Desktop.
dynamically generates equal sized dividers for a row of display content based upon the length of the desired line, number of columns, its content and available empty space.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $PARTITION = "================================================================================\n"; | |
my $PARTITIONLENGTH = length($PARTITION)-1;#-1 to remove newline from count | |
my $emptySpaceLen = $PARTITIONLENGTH - length($partOne.$partTwo.$partThree.$partFour); | |
my $divider = makeDivider($emptySpaceLen, 4); | |
my $return = "$partOne$divider$partTwo$divider$partThree$divider$partFour\n"; | |
$return .= $PARTITION; #for this application i needed a partition after each section | |
return $return; | |
sub makeDivider{#first arg is length of content second is number of columns | |
my $div; | |
for (1 .. $_[0]/($_[1]-1)){ | |
$div .= ' '; | |
} | |
return $div; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment