An (optional) exercise to test your skills

Look at our pick-primers.pl script: I added some ASCII characters to draw a box around the welcome screen. Now it looks like:

print STDERR "
 +----------------------------------------------+
 |   Pick Primer Tool v.01                      |
 |                                              | 
 |   Parameters:                                |
 |   contig1 direction1 contig2 direction2      |
 |                                              |
 |   direction1,2 = U or C                      |
 +----------------------------------------------+
";

Nice, isn’t it? Yes, we can do much better, like (google ASCII-art for more fun):

-._    _.--'"`'--._    _.--'"`'--._    _.--'"`'--._    _  
    '-:`.'|`|"':-.  '-:`.'|`|"':-.  '-:`.'|`|"':-.  '.` : '.   
  '.  '.  | |  | |'.  '.  | |  | |'.  '.  | |  | |'.  '.:   '.  '.
  : '.  '.| |  | |  '.  '.| |  | |  '.  '.| |  | |  '.  '.  : '.  `.
  '   '.  `.:_ | :_.' '.  `.:_ | :_.' '.  `.:_ | :_.' '.  `.'   `.
         `-..,..-'       `-..,..-'       `-..,..-'       `         `

but this is not the main aim of this post. Rather I’d like you think how to make a subroutine that creates a frame around a multiline text. We can call it “boxprint”, and it will expect a multi-line text. We can invoke it with something like:

boxprint("
 Pick Primer Tool v.01                     
 
 Parameters:                               
 contig1 direction1 contig2 direction2     
 
 direction1,2 = U or C                     
");

and we expect to obtain a boxed message.
You can use this page to create the script and test it live…

Tagged

One thought on “An (optional) exercise to test your skills

  1. proch says:

    The solution is published here:
    http://codepad.org/dXepm4PK

Leave a Reply

Your email address will not be published. Required fields are marked *