Multiple choice technology programming languages

Which operator can be used to create private variables within a subroutine?

  1. native

  2. limited

  3. my

  4. regional

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The my operator creates lexical variables in Perl, which are private to their scope. This is Perl's mechanism for creating private variables within subroutines.

AI explanation

my is correct. In Perl, my declares a lexically scoped variable — private to the enclosing block, subroutine, or file — as opposed to Perl's global/package variables. This is the standard way to create private/local variables inside a subroutine so they don't leak into or collide with the wider program's namespace. native, limited, and regional are not Perl keywords at all; they're plausible-sounding but fictitious distractors. (Perl also has our, for declaring lexically-scoped aliases to package globals, and local, for dynamically-scoped temporary overrides of globals — but neither of those appears among the choices here.)