Hello monks, I am attempting to print every other line of output in color using Term::ANSIColor and printf. I have managed to sort of pull off what I am trying by the following code
my $c = 0;
printf("\n%-7s %-22s %-18s %-35s %-15s %-16s %-30s\n\n", "ID","MAC","I
+P","Manufacturer","Authorized","Acknowledged","Notes");
while(@row = $sth->fetchrow_array){
my ($id,$mac,$ip,$man,$auth,$ack,$notes) = @row;
push @device_ids, $id;
if ($c == 1){
printf(
"%-7s %-22s %-18s %-35s %-15s %-16s %-30s\n",
colored("$id", 'bold blue on_grey10'),
colored("$mac", 'bold blue on_grey10'),
colored("$ip", 'bold blue on_grey10'),
colored("$man", 'bold blue on_grey10'),
colored("$auth", 'bold blue on_grey10'),
colored("$ack", 'bold blue on_grey10'),
colored("$notes", 'bold blue on_grey10'),
);
$c--;
}
else{
printf("%-7s %-22s %-18s %-35s %-15s %-16s %-30s\n", "$id"
+,"$mac","$ip","$man","$auth","$ack","$notes");
$c++;
}
$cnt++;
}
but what seems to happen when I run it is the printf formatting is not applied. I'd like the entire row to be highlighted and formatted not just the individual fields (so the spaces too).
As always, thanks for the help in advanced
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.