$ perl -E ' use List::Util "first"; use Tk; my $mw = MainWindow->new; my @font_prefs = ("Consolas", "Lucida Console", "Courier"); my %font_have = map { fc $_ => 1 } $mw->fontFamilies; my $font_best = first { exists $font_have{fc $_} } @font_prefs; say $font_best ' Courier