use 5.012; use warnings; use File::Spec; my ($sep, $exe) = do { if ($^O =~ /^MSWin/) { (';', '.exe') } else { (':', '') } }; sub findgs { for my $dir (split $sep, $ENV{PATH}) { my $_ = File::Spec->catfile($dir, "gs$exe"); return $_ if -x; } } if (my $gs = findgs) { say "ghostscript found: $gs"; } else { warn "ghostscript not found"; }