try to use Module in Perl and print message if module not available

前端 未结 6 781
伪装坚强ぢ
伪装坚强ぢ 2020-12-14 02:38

I wanted to be able to do this in Perl (the code below is Python lol)

try:
  import Module
except:
  print \"You need module Module to run this program.\"
         


        
6条回答
  •  不思量自难忘°
    2020-12-14 03:12

    use strict;
    use warnings;
    use Module;
    

    If you don't have Module installed, you will get the error "Can't locate Module.pm in @INC (@INC contains: ...)." which is understandable enough.

    Is there some particular reason you want/need a more specific message?

提交回复
热议问题