Help us understand the problem. What is going on with this article?

perl上でexit codeを取得する際は要注意

More than 5 years have passed since last update.

system('date')とかでシステムコールした際のexit codeを取りたい時注意。

どうしたらいいの?

exit code取りたいだけならこうしておく。

my $code = system('date') >> 8

なんで?

unix的な戻り値を返すらしい。
左8bit: exit code
右8bit: コアダンプの有無とか停止時のシグナルとか

参照

perldoc
http://perldoc.jp/variable/%24%3F

ir-yk
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away