Hi guys. Thanks again for all the comments. While I was playing with this, I had the "old way" (with the extra pipe) and the "new way" printing at the same time, and the top line was longer than the second, and it looked cool. So I decided to try to divise a programmatic way to split the line into two, with the top part never having less elements than the second. My algorithm was to take the final string, count the number of pipes in it, and then turn the "middle" one (and, if no clear "middle," then skew towards later in the string) into a br tag. Here's what I came up with:
my $homes=join(" |",@la);
#print $homes;
my @pipes;
my $pos;
while ($homes =~ m/\|/g){
push @pipes, pos($homes)-1;
}
my $numps=scalar(@pipes);
my $ptr= $numps-int($numps/2); #no ceil() function in perl
substr($homes,$pipes[$ptr],1,"<br>");#not catching rv--is that bad?
print $homes;
I know there are probably better ways, but I kind of had fun figuring this out in a way that's flexible if sections are added/subtracted.
I like computer programming because it's like Legos for the mind.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.