Ilya Verlinsky > Data-MaskPrint-1.0 > Data::MaskPrint

Download:
Data-MaskPrint-1.0.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.0   Source  

NAME ^

MaskPrint - Data format module.

SYNOPSIS ^

 use strict;
 use Data::MaskPrint;

 my $ftm = new Data::MaskPrint();
 my $formatted_data = $fmt->num_mask_print(1234, '$$,$$$.&&')

DESCRIPTION ^

Data::MaskPrint::new()

Creates a new formatter

Data::MaskPrint::num_mask_print($data, $mask)
$data - numeric data value
$mask - mask value

DESCRIPTION OF MASKS

Formatting Number Expressions

The format string (mask) consists of combination of the following characters: * & # < , . - + ( ) $. The characters - + ( ) $ will float. When character floats MaskPrint display multiple leading occurances of the character as the single character as far to the right as possible, without interfering with the number that is being displayed.

'*'

This character fills with asterisks any positions that would otherwise be blank

'&'

This character fills with 0 any positions that would otherwise be blank

'#'

This character does not change any blank positions in the display field. Use this character to specify max. width of the field.

'<'

This character causes numbers to be left-justified

','

This character is a literal it displays ,. It will not dispay , if there is no numbers to the left

'.'

This character is a literal it displays . (Only one is allowed per string)

'-'

This character is a literal it displays - sign if expression is < 0. When you group several in a row, it will float to the rightmost position without interfering with the numbers being printed.

'+'

This character is a literal it displays '-' sign if expression is < 0 and '+' if expression is > 0. When you group several in a row, it will float to the rightmost position without interfering with the numbers being printed.

'('

This character is a literal it displays accounting parenthesis is expression is < 0 (Instead of the minus sign). When you group several in a row, it will float to the rightmost position without interfering with the numbers being printed.

')'

This character is a literal it displays accounting parenthesis is expression is < 0 (Instead of the minus sign). Only one is allowed per mask.

'$'

This character is a literal it displays $. When you group several in a row, it will float to the rightmost position without interfering with the numbers being printed.

Examples of masks

Format String Data Value Formatted Result

'#####' 0 bbbb0 '&&&&&' 0 00000 '$$$$$' 0 bbb$0 '*****' 0 ****0 '##,###' 12345 12,345 '##,###' 1234 b1,234 '##,###' 123 bbb123 '##,###' 12 bbbb12 '##,###' 1 bbbbb1 '##,###' -1 bbbb-1 '##,###' 0 bbbbb0 '&&,&&&' 12345 12,345 '&&,&&&' 1234 01,234 '&&,&&&' 123 000123 '&&,&&&' 12 000012 '&&,&&&' 1 000001 '&&,&&&' 0 000000 '$$,$$$' 12345 ****** (overflow)

'$$,$$$' 1234 $1,234 '$$,$$$' 123 bb$123 '$$,$$$' 12 bbb$12 '$$,$$$' 1 bbbb$1 '$$,$$$' 0 bbbb$0 '**,***' 12345 12,345 '**,***' 1234 *1,234 '**,***' 123 ***123 '**,***' 12 ****12 '**,***' 1 *****1 '**,***' 0 *****0 '##,###.##' 12345.67 12,345.67 '##,###.##' 1234.56 b1,234.56 '##,###.##' 123.45 bbb123.45 '##,###.##' 12.34 bbbb12.34 '##,###.##' 1.23 bbbbb1.23 '##,###.##' 0.12 bbbbb0.12 '##,###.##' 0.01 bbbbb0.01 '##,###.##' -0.01 bbbb-0.01 '##,###.##' -1 bbbb-1.00 '&&,&&&.&&' 12345.67 12,345.67 '&&,&&&.&&' 1234.56 01,234.56 '&&,&&&.&&' 123.45 000123.45 '&&,&&&.&&' 0.01 000000.01 '$$,$$$.$$' 12345.67 ********* (overflow)

'$$,$$$.$$' 1234.56 $1,234.56 '$$,$$$.##' 0 bbbb$0.00 '$$,$$$.##' 1234 $1,234.00 '$$,$$$.&&' 0 bbbb$0.00 '$$,$$$.&&' 1234 $1,234.00 '-##,###.##' -12345.67 -12,345.67 '-##,###.##' -123.45 -bbb123.45 '-##,###.##' -12.34 -bbbb12.34 '--#,###.##' -12.34 b-bbb12.34 '---,###.##' -12.34 bbb-b12.34 '---,-##.##' -12.34 bbbb-12.34 '---,--#.##' -1 bbbbb-1.00 '-##,###.##' 12345.67 b12,345.67 '-##,###.##' 1234.56 bb1,234.56 '-##,###.##' 123.45 bbbb123.45 '-##,###.##' 12.34 bbbbb12.34 '--#,###.##' 12.34 bbbbb12.34 '---,###.##' 12.34 bbbbb12.34 '---,-##.##' 12.34 bbbbb12.34 '---,---.##' 1 bbbbbb1.00 '---,---.--' -0.01 bbbbb-0.01 '---,---.&&' -0.01 bbbbb-0.01 '-$$,$$$.&&' -12345.67 ********** (overflow)

'-$$,$$$.&&' -1234.56 -$1,234.56 '-$$,$$$.&&' -123.45 bb-$123.45 '--$,$$$.&&' -12345.67 **********

                                        (overflow)
'--$,$$$.&&'        -1234.56            -$1,234.56          
'--$,$$$.&&'        -123.45             bb-$123.45          
'--$,$$$.&&'        -12.34              bbb-$12.34          
'--$,$$$.&&'        -1.23               bbbb-$1.23          
'----,--$.&&'       -12345.67           -$12,345.67         
'----,--$.&&'       -1234.56            b-$1,234.56         
'----,--$.&&'       -123.45             bbb-$123.45         
'----,--$.&&'       -12.34              bbbb-$12.34         
'----,--$.&&'       -1.23               bbbbb-$1.23         
'----,--$.&&'       -0.12               bbbbb-$0.12         
'$***,***.&&'       12345.67            $*12,345.67         
'$***,***.&&'       1234.56             $**1,234.56         
'$***,***.&&'       123.45              $****123.45         
'$***,***.&&'       12.34               $*****12.34         
'$***,***.&&'       1.23                $******1.23         
'$***,***.&&'       0.12                $******0.12         
'($$$,$$$.&&)'      -12345.67           ($12,345.67)        
'($$$,$$$.&&)'      -1234.56            (b$1,234.56)        
'($$$,$$$.&&)'      -123.45             (bbb$123.45)        
'(($$,$$$.&&)'      -12345.67           ($12,345.67)        
'(($$,$$$.&&)'      -1234.56            ($1,234.56)         
'(($$,$$$.&&)'      -123.45             (bb$123.45)         
'(($$,$$$.&&)'      -12.34              (bbb$12.34)         
'(($$,$$$.&&)'      -1.23               (bbbb$1.23)         
'((((,(($.&&)'      -12345.67           ($12,345.67)        
'((((,(($.&&)'      -1234.56            ($1,234.56)         
'((((,(($.&&)'      -123.45             (b$123.45)          
'((((,(($.&&)'      -12.34              ($12.34)            
'((((,(($.&&)'      -1.23               ($1.23)             
'((((,(($.&&)'      -0.12               ($0.12)             
'($$$,$$$.&&)'      12345.67            $12,345.67          
'($$$,$$$.&&)'      1234.56             $1,234.56           
'($$$,$$$.&&)'      123.45              $123.45             
'(($$,$$$.&&)'      12345.67            $12,345.67          
'(($$,$$$.&&)'      1234.56             $1,234.56           
'(($$,$$$.&&)'      123.45              $123.45             
'(($$,$$$.&&)'      12.34               $12.34              
'(($$,$$$.&&)'      1.23                $1.23               
'((((,(($.&&)'      12345.67            $12,345.67          
'((((,(($.&&)'      1234.56             $1,234.56           
'((((,(($.&&)'      123.45              $123.45             
'((((,(($.&&)'      12.34               $12.34              
'((((,(($.&&)'      1.23                $1.23               
'((((,(($.&&)'      0.12                $0.12               
'<<<<<'             0                   0                   
'<<<,<<<'           12345               12,345              
'<<<,<<<'           1234                1,234               
'<<<,<<<'           123                 123                 
'<<<,<<<'           12                  12                  

AUTHOR ^

Send bug reports, hints, tips, suggestions to Ilya Verlinsky <ilya@wsi.net>.

syntax highlighting: