6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

strict.pm が無い環境でも一応エラーにならない use strict の書き方

Posted at

具体的に言うと、@nifty の「@homepage」(LaCoocanじゃねーぞ)の Perl は strict.pm すら無くてだなぁ、今まで @homepage 向けにいちいち

# use strict; use warnings

などとコメントアウトしていた。だが、最初から

BEGIN{
    eval{ require 'strict.pm';   }; strict  ->import() unless $@;
    eval{ require 'warnings.pm'; }; warnings->import() unless $@;
}

等と書いておくと

  • strict.pm がある環境では、use strict; 相当の動作をさせる
  • strict.pm がない環境では、スルー

させることが可能だと気付いた。

とは言え、きょうび、そんな環境ほとんどないし、唯一と言っても過言ではない @homepage も2010年1月31日で新規受付終了してるし、これも完全にロストテクノロジーだなぁ。

6
6
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?