Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

POD Figlet titles

by chanio (Priest)
on Jan 05, 2006 at 17:22 UTC ( #521286=CUFP: print w/ replies, xml ) Need Help??

Perhaps, you are like me that need to see the title of the printed script in a huge format.

You don't need to have a POD written at the starting of the script. You can just have a 5-6 lines of comments after the shebang. And use it to put the script's title in figlet format.

This is what you need to do it in LINUX...

  • Install the Text_Figlet module.
  • Get the figlet fonts
  • add this code to your ~/.bashrc file:(* updated, THXS Tanktalus !)
    ... ## PARA LETRAS FIGLET EN PERL (SOLAMENTE) export FIGLIB=$HOME/path/where/you/placed/your/fonts:$HOME/another/pat +h/with/fonts ## [figlet "text" (name ffont) ] writes sent msg in big (optional: cho +oses a ffont) figlet() { local que=$1 local fu=timesofl if [ ! -z "$2" ] then local fu=$2 fi; if [ -n "$que" ] then perl -I$HOME/path/to/installed/FIGlet.pm -MText::FIGlet -e 'pr +int Text::FIGlet->new( -f=>$ARGV[0] )->figify( -A=>$ARGV[1] )' "$fu" +"$que" fi; } ...
  • Then try it in a new shell session (you need 'Courrier New' font to see it well):
    figlet "HAPPY 2006"
    ##  ##############################################    ####    ####    ####    ##
    #  ##############################################  ##  ##  ##  ##  ##  ##  ##  #
    # ##  #####  #### #   ### #   ###  ##  ##############  ##  #   ##  #   ##  #####
    # # #  ### #  ##   ##  #   ##  #   ##  #############  ###   #  ##   #  ##     ##
    #  ##  ##  #  ###  ##  ##  ##  ### ## ############  #####  ##  ##  ##  ##  ##  #
    #  ##  ##  #  ###     ###     ####    ###########  ######  ##  ##  ##  ##  ##  #
    #  ##   ##  #  ##  ######  ########  ############      ###    ####    ####    ##
    ################    ####    #####   ############################################
    
  • or choose another ffont:
    figlet "HAPPY 2006" avatar
     _     ____  ____  ____ ___  _ ____  ____  ____     _
    / \ /|/  _ \/  __\/  __\\  \///_   \/  _ \/  _ \ __/ \
    | |_||| / \||  \/||  \/| \  /  /   /| / \|| / \|/__  |
    | | ||| |-|||  __/|  __/ / /  /   /_| \_/|| \_/||\/  |
    \_/ \|\_/ \|\_/   \_/   /_/   \____/\____/\____/\____/
    
If you edit your code with SCITE, just format your comments with a monospaced font (they would read better and support figlet and ASCII-Art...)!

I made a nice example of its use while building a FREE 2006 Tree-Pad calendar. You'll need the freeware plain text editor with tabs (TreePad Lite) to use it!

Comment on POD Figlet titles
Select or Download Code
Re: POD Figlet titles
by Tanktalus (Canon) on Jan 05, 2006 at 22:34 UTC

    A couple minor points. First, "! -z" is more commonly known as "-n". Second, if you're running perl from the commandline anyway, use lib is usually called -I, while all other uses are called -M. And rather than dealing with lots of annoying quotes, just pass in your parameters.

    figlet() { local que=$1 local fu=timesofl if [ -n "$2" ] then local fu=$2 fi; if [ -n "$que" ] then perl -I$HOME/path/to/installed/FIGlet.pm -MText::FIGlet -e 'pr +int Text::FIGlet->new(-f=>$ARGV[0])->figify(-A=>$ARGV[1])' "$fu" "$qu +e" fi; }
    Unlike in perl where quoting a variable is a waste of time, in shell it's imperative to keep any embedded spaces unchanged. Having moved your variables from inside the perl code to purely in shell, I need to keep the quotes - but I can get rid of leaning toothpick syndrome (LTS). And then I can switch your double quotes to single quotes and now I think the whole command is much easier to look at. Personally, I would have made the whole thing just a perl script to begin with:
    #!/usr/bin/perl use lib "..."; # probably not really needed. use Text::FIGlet; my $figlet = Text::FIGlet->new(-f => $ARGV[1] || 'timesofl'); print $figlet->figify(-A => shift);
    Of course, I'd add more comments and whatever. ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://521286]
Approved by willyyam
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2014-12-18 23:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (67 votes), past polls