I have used the following Perl setup for years...
use Term::Cap;
use Term::ANSIColor qw(:constants);
use POSIX;
my $TermIOs = new POSIX::Termios;
$TermIOs->getattr;
my $OSpeed = $TermIOs->getospeed;
my $terminal = Tgetent Term::Cap { TERM => undef, OSPEED => $OSpeed };
(${norm}, ${bold}, ${under}) = map { $terminal->Tputs($_,1) } qw/me md us/;
...which allows me to change printed terminal text, e.g.:-
print ("\nModels will be limited to ${bold}$ModelArch${norm} systems greater than or equal to ${bold}$ModelMinSpeed${norm}.\n");
...and it has always worked fine. But now I am in a situation where I need to change shells and activate a big environment with hundreds of variables and $PATH manipulation. Once I do that, the above code starts throwing out the following:-
Can't find a valid termcap file at ugeqstat.pl line 16.
I can do a "man termcap" before and after the environment change and the results are the same. My $TERM value has not changed either. Is there a dependable way to avoid a simple complication like this? I guess I need to switch to something like Term::ANSIColor qw(:constants), which may be less prone to this issue, but it would require a lot of tedious script updates.