How to terminate a program in Perl - exit or die?

后端 未结 3 1431
隐瞒了意图╮
隐瞒了意图╮ 2021-02-05 02:08

I am using syntax checking to see whether my Perl script is being used in the correct way. If the syntax is not correct, I display a message saying what the correct syntax is, a

3条回答
  •  灰色年华
    2021-02-05 02:55

    print prints to STDOUT but die prints to STDERR

    exit 1 exits with exit status of 1 but die exits with exit current value of errno that is $!

    Hence die is the preferred way as its simpler and shorter.

提交回复
热议问题