2
2

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.

Perlのこの特殊変数の意味は?

Posted at

というときはperldoc -vを使う。
全部見たいときはperldoc perlvarから探しても良い。

$ perldoc -v '$!'
    $OS_ERROR
    $ERRNO
    $!      When referenced, $! retrieves the current value of the C "errno"
            integer variable. If $! is assigned a numerical value, that value
            is stored in "errno". When referenced as a string, $! yields the
            system error string corresponding to "errno".

            Many system or library calls set "errno" if they fail, to indicate
            the cause of failure. They usually do not set "errno" to zero if
            they succeed. This means "errno", hence $!, is meaningful only
            immediately after a failure:

                if (open my $fh, "<", $filename) {
                            # Here $! is meaningless.
                            ...
                }
                else {
                            # ONLY here is $! meaningful.
                            ...
                            # Already here $! might be meaningless.
                }

参考

perldocべんりってはなし - Qiita

2
2
0

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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?