$!
ErrorsCollection

$!

Synthesised documentation from language/variables

From language/variables

See Original text in context

$! is the error variable. A fresh one is created in every routine. If a try block or statement prefix catches an exception, that exception is stored in $!. If no exception was caught, $! is set to Nil.

Note that CATCH blocks do not set $!. Rather, they set $_ inside the block to the caught exception.

Also note that the same thread-safety issues apply to the use of $! as they do to $/.