I have some pretty simple perl code which relies on Term::ReadKey
to get the terminal width; My NetBSD build is missing this module, and I want to default to 80 when the module is missing.
The odd thing is, I can't figure out how to conditionally use a module, knowing ahead of time whether it is present. This code would just quit saying it can't find Term::ReadKey if it actually can't.
#/usr/pkg/bin/perl -w
# Try loading Term::ReadKey
use Term::ReadKey;
my ($wchar, $hchar, $wpixels, $hpixels) = GetTerminalSize();}
my @p=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97);
my $plen=$#p+1;
printf("num |".("%".int(($wchar-5)/$plen)."d") x $plen."\n",@p);
I'm using Perl 5.8.7 on NetBSD and 5.8.8 on CygWin