If you look at the error more carefully, it is generated by mkpath(), not yours.
From the File::Path manpage:
Quote:
|
If a system error prevents a directory from being created, then the mkpath function throws a fatal error with Carp::croak . This error can be trapped with an eval block:
|
As you don't trap the error with eval, the program terminates with the error as expected.