I prefer Perl's approach for both:

    use v5.40;

    ....

That's explicit, tied to a specific version, and executable code which can be scoped to a single source file.

(I'd argued for that feature for years with my `Modern::Perl` feature bundle; glad to see that can be deprecated now.)