View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Manish Grewal > Text-7Segment-v0.0.1_0 > _


Annotate this POD

Source   Latest Release: Text-7Segment-v0.0.1_1


Text::7Segment - Display characters in  | segment style.


This documentation refers to Text::7Segment version 0.0.1_0. This is alpha version, interface is likely to change slightly.


        use Text::7Segment;

        my $seg7 = Text::7Segment->new();
        $seg7->disp_str(':0123456789 abcdef ABCDEJ');

        # all hex digits available in both upper and lower case
        $seg7->disp_str(':0123456789 abcdef ABCDEF');

        # start display at 5th row from top and 
        # 10th character from left 
        my $seg7 = Text::7Segment->new( x_init => 10, y_init => 5);

        # 7-segment led clock
        my $seg7 = Text::7Segment->new( );
        while (1) {
                chomp(my $time = qx/date '+%T'/);



                sleep 1;


This module will display strings in 7 segment style. This is the common display style used in lcd calculators, digital watches etc.

The module takes only the hex digits([0-9A-Fa-f]), colon (:) and space characters (at present).

The intended application of this module is to emulate a seven segment clock or calculator display just for fun.

If you are still in the dark or need more info please refer to for lots of details on this display technology.


A Text::7Segment object is an instance of a 7-segment display. The following methods can be called on the object:


If the string contains a character outside of the character class [a..fA..F0..9: ], it will not be displayed and a warning will be given. It will be a good idea to redirect the error output to somewhere other than the terminal if this is likely.

        Warning: Code not defined for $chr


Any output to the terminal can wreak havoc with the curses display. If the string to be displayed can have an unsupported character, it would be better to redirect STDOUT to a file or another place away from STDOUT. E.g.,

        perl 2>/dev/null
        perl 2>error.out


This module depends on the Curses module for displaying the output. It could be done without curses in a text terminal but then the input will have to be line bufferred. i.e the module should get the whole line of string at a time because it couldn't go back to top row after moving to the 2nd or 3rd.


It seems to get stuck at end of screen. Need to handle y_curr when it reaches max value.

Sometimes the terminal needs to be reset after a script using the module terminates. The terminal is still usable but the prompt gets shifted to the right. Just typing reset at the prompt and hitting enter seems to fix the issue for me.

Please report problems to manigrew ( Patches are welcome.


Following is a quick List of future enhancements off the top of my head based on what i have seen around the web for similar functionality.

- support different size of character - not just 3x3, e.g like bsd banner command - allow lookup func override if not already available and also good to have an example of how it should be subclassed. - use standard conventional letters for segments (a..g) in var names/comments - use colors

Immediate todo:

- mention defaults - say char class once and ref from there


manigrew (


Copyright (c) 2013 manigre ( All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

syntax highlighting: