In Statement prefixes§

See primary documentation in context for try.

If you use try in front of a statement, it will contain the exception produced in it and store it in the $! variable, just like when it's used in front of a block.

try [].pop;
say $!; # OUTPUT: «Cannot pop from an empty Array␤..»

Note that if no Exception had been thrown in the try block, then $! will be undefined.