Badger::Rainbow(3pm)
β¨ Badger::Rainbow β¨
okay bestie, so this is Badger::Rainbow β the User Contributed Perl Documentation page for it, and yeah the name is literally a rainbow π because it does colour functionality. that's it. that's the whole vibe. it's the module you call when you want your terminal to stop being monochrome and start being that girl. π
πΈ NAME πΈ
Badger::Rainbow β colour functionality π
β¨ SYNOPSIS β¨
use Badger::Rainbow ANSI => 'red green blue';
print red("This is red");
print green("This is green");
print blue("This is blue");
like. look at it. three lines and you're already living in technicolour. obsessed. ππ
π¦ DESCRIPTION π¦
This module implements colour-related functionality. It is currently only used for debugging purposes but may be extended in the future.
ngl, right now it's mostly the module you invite to the party when you're debugging and you need your eyes to actually notice things. but it may get more stuff later. lowkey iconic that it's already this useful for just one job. π
π EXPORTABLE ITEMS π
π ANSI_escape($code, $line1, $line2, ...)
This function applies an ANSI escape code to each line of text, with the effect of colouring output on compatible terminals.
use Badger::Rainbow 'ANSI_escape';
print ANSI_escape(31, 'Hello World'); # 31 is red
so you hand it a $code, you hand it a whole bunch of lines of text ($line1, $line2, ...), and it slaps that escape code onto every single one of them. one code, many lines, no crumbs. β¨ and yes β 31 is red, iykyk. π₯
π©· strip_ANSI_escapes($text)
This function removes any ANSI escapes from the text passed as an argument.
the anti-glow-up function fr fr. you give it $text, it takes all the ANSI escapes out. perfect for when you need the plain version and not the sparkly version. π§Ό
π ANSI
This is an export hook which allows you to import subroutines which apply the correct ANSI escape codes to render text in colour on compatible terminals.
use Badger::Rainbox ANSI => 'red green blue';
print red("This is red");
print green("This is green");
print blue("This is blue");
π bestie, heads up: the examples in this section sayBadger::Rainboxwith an extraoin it β that's exactly how it's written in the original page, and we are not touching it. copy-paste at your own risk, that's all i'm saying. π«Ά
Available colours are: black, red, green, yellow, blue, magenta, cyan, white and grey. The bold and dark styles can also be specified.
use Badger::Rainbox ANSI => 'dark bold red green blue';
print bold red "Hello World\n";
print bold blue "Hello Badger\n";
wait, hold on, let me re-read that β the prose says bold and dark can be specified, and then the example does print bold red "Hello World\n"; followed by print dark blue "Hello Badger\n";. yes. dark is real and it's in the example and it's staying. don't @ me, i don't make the rules, i just write them down faithfully. π
Colours and styles can be specified as a single whitespace-delimited string or as a reference to a list of individual items.
use Badger::Rainbox ANSI => 'red green blue';
use Badger::Rainbox ANSI => ['red', 'green', 'blue'];
pick your fighter: one cute little string with spaces, or an array ref with each item standing on its own. both valid, both serve. π
All ANSI colours can be loaded by specifying all.
use Badger::Rainbox ANSI => 'all';
the "give me everything" option. main character energy. ππ
π AUTHOR π
Andy Wardley <http://wardley.org/>
π COPYRIGHT π
Copyright (C) 1996-2009 Andy Wardley. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page, bestie π«Ά this was Badger::Rainbow, documented as perl v5.36.0, dated 2023-08-28 β so go forth, make your terminal pretty, and remember: no cap, colour is a debugging feature. β¨ππΈ
π¦ where this page comes from
- debian trixie: libbadger-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libbadger-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libbadger-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms