Challenge 2: The $@ Capture Pattern — Possible Solution ==================================================================== use strict; use warnings; use feature 'say'; eval { die "Something broke\n"; }; my $err = $@; if ($err) { say "Caught: $err"; } # Capturing $@ into my $err immediately, right after the eval block, # is safer than checking $@ directly later because $@ is a GLOBAL # variable that anything running between the eval and a later check # — another unrelated eval, or a DESTROY method firing during garbage # collection — could silently overwrite in the meantime. Output: Caught: Something broke WHY THIS WORKS AS AN ANSWER ------------------------------ eval { die "..."; }; reuses the chapter's own classic eval/$@ pattern directly — the die inside the block is caught by eval rather than terminating the script, and $@ becomes populated with the message. my $err = $@; immediately after the eval block reuses the chapter's own recommended safety practice exactly — copying $@'s current value into a fresh, ordinary lexical variable right away, before anything else has a chance to run and potentially clobber the global $@ in the meantime. The one-sentence explanation reuses the chapter's own warn-box reasoning almost word for word — "$@ is a global, and anything that runs between your eval and your check of $@... can silently overwrite it" — restated here specifically to answer why the my $err = $@; line matters, rather than just checking if ($@) { ... } directly several lines later, where more code (and more chances for $@ to change) could have run in between.