Hello, is there a way to get with printf colored output?
#!/usr/bin/perl
use warnings;
use strict;
use Term::ANSIColor;
printf "%4.4s\n", colored( '0123456789', 'magenta' );
Output: (only newline)
Hello, is there a way to get with printf colored output?
#!/usr/bin/perl
use warnings;
use strict;
use Term::ANSIColor;
printf "%4.4s\n", colored( '0123456789', 'magenta' );
Output: (only newline)
You need to change your code like the following
printf "%s\n", colored( '0123456789', 'magenta' );
Because we can't get the first 4 character in the string. If you give the string value to the printf function it will print the value up to null character. We can't get the first 4 characters.
I assume you want something like the following:
#!/usr/bin/perl
use warnings;
use strict;
use Term::ANSIColor;
print colored( sprintf("%4.4s", '0123456789'), 'magenta' ), "\n";