SPVM::Format - Format Utilities
use Format; # %d - "123" my $formatted_string = Format->sprintf("%d", 123); # %5d - " 123" my $formatted_string = Format->sprintf("%5d", 123); # %05d - "00123" my $formatted_string = Format->sprintf("%05d", 123); # %+d - "+123" my $formatted_string = Format->sprintf("%+d", 123); # %-5d - "123 " my $formatted_string = Format->sprintf("%-5d", 123); # %d - "x" my $formatted_string = Format->sprintf("%c", 'x'); # %c - "あ" my $formatted_string = Format->sprintf("%c", Format->ord("あ")); # %s - "ABC" my $formatted_string = Format->sprintf("%s", "ABC") eq "ABC"); # %u - "4294967295" my $formatted_string = Format->sprintf("%u", -1) eq "4294967295"); # %f - "3.141500" my $formatted_string = Format->sprintf("%f", 3.1415) eq "3.141500"); # %.2f - "3.14" my $formatted_string = Format->sprintf("%.2f", 3.1415) eq "3.14"); # %g - "3.14" my $formatted_string = Format->sprintf("%g", 3.14) eq "3.14"); # %x - "ff" my $formatted_string = Format->sprintf("%x", 255) eq "ff"); # %x - "ffffffff" my $formatted_string = Format->sprintf("%x", -1) eq "ffffffff");
Format is a formatting utilities such as sprintf method.
Format
sprintf
Class method of Format module.
static method sprintf : string ($format : string, $args : object[]...)
Create a formatted string with the format and the values.
UTF-8
0-9a-z
0-9A-Z
Specifier Options:
Specifier options can be written between % and the character of specifier such as d, f.
%
d
f
Examples:
# %d - "123" my $formatted_string = Format->sprintf("%d", 123); # %5d - " 123" my $formatted_string = Format->sprintf("%5d", 123); # %05d - "00123" my $formatted_string = Format->sprintf("%05d", 123); # %+d - "+123" my $formatted_string = Format->sprintf("%+d", 123); # %-5d - "123 " my $formatted_string = Format->sprintf("%-5d", 123); # %d - "x" my $formatted_string = Format->sprintf("%c", 'x'); # %c - "あ" my $formatted_string = Format->sprintf("%c", Format->ord("あ")); # %s - "ABC" my $formatted_string = Format->sprintf("%s", "ABC") eq "ABC"); # %u - "4294967295" my $formatted_string = Format->sprintf("%u", -1) eq "4294967295"); # %f - "3.141500" my $formatted_string = Format->sprintf("%f", 3.1415) eq "3.141500"); # %.2f - "3.14" my $formatted_string = Format->sprintf("%.2f", 3.1415) eq "3.14"); # %g - "3.14" my $formatted_string = Format->sprintf("%g", 3.14) eq "3.14"); # %x - "ff" my $formatted_string = Format->sprintf("%x", 255) eq "ff"); # %x - "ffffffff" my $formatted_string = Format->sprintf("%x", -1) eq "ffffffff");
To install SPVM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SPVM
CPAN shell
perl -MCPAN -e shell install SPVM
For more information on module installation, please visit the detailed CPAN module installation guide.