[ create a new paste ] login | about

Link: http://codepad.org/dXepm4PK    [ raw code | output | fork ]

proch - Perl, pasted on Mar 27:
boxprint("
My program v. 1.0

Parameters:
FASTA-filename Coverage ReadLength");


sub boxprint {
 $max = 0;
 # Receive input: its a multiline string
 $string = $_[0];

 # Split on newline: now I have an array
 # with all the lines
 @lines = split (/\n/, $string);

 # I perform a first cycle to detect the longest
 # line
 foreach $l (@lines) {
   $max = length($l) if ($max<length($l));
 }
 
 # Prepare a separator $max character long
 $sep = '-' x $max;
 # Print first line
 print '+-'.$sep."-+\n";
 # Second cycle to surround each line with vertical
 # bars (|)

 foreach $l (@lines) {
   $cur = length($l);
   $space=' ' x ($max-$cur);
   $l = '| '.$l.$space.' |';
   print "$l\n";
 }
 # Final separator
 print '+-'.$sep."-+\n";
}


Output:
1
2
3
4
5
6
7
+------------------------------------+
|                                    |
| My program v. 1.0                  |
|                                    |
| Parameters:                        |
| FASTA-filename Coverage ReadLength |
+------------------------------------+


Create a new paste based on this one


Comments: