Skip to content

Instantly share code, notes, and snippets.

@AndrewRussellHayes
Created November 20, 2013 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewRussellHayes/7566936 to your computer and use it in GitHub Desktop.
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.
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