And now, thanks to perl, I can easily solve a problem that was too much bother to deal with before...
Internet guitar tab is the bastard child of ASCII art and musical notation. It looks like this, and as you can see, it's most undesirable to have a page break in the middle of a line of tab (which consists of 6 or more lines of text).
So I wrote this script to prevent paragraphs from spanning a page break. Perhaps someone's done this before but I figured it would be good practice... what do you guys think?
#!/usr/bin/perl -w use strict; use constant LPP => 63; # for enscript my @chunk = (); my $line = 0; while (<>) { if (/^\s*$/) { &printchunk; ++$line; print; } else { push @chunk,$_; } } &printchunk; sub printchunk { if (@chunk + $line >= LPP) { print "\n" while $line++ < LPP; $line = 0; } $line += @chunk; print @chunk; @chunk = (); }
In reply to page break at paragraph break by dbw
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |