Perl Programming Question:

If EXPR is an arbitrary expression, what is the difference between $Foo::{EXPR} and *{"Foo::".EXPR}?

Tweet Share WhatsApp

Answer:

The second is disallowed under `use strict "refs"'.
Dereferencing a string with *{"STR"} is disallowed under the refs stricture, although *{STR} would not be. This is similar in spirit to the way ${"STR"} is always the symbol table variable, while ${STR} may be the lexical variable. If it's not a bareword, you're playing with the symbol table in a particular dynamic fashion.

Download Perl Programming PDF Read All 46 Perl Programming Questions
Previous QuestionNext Question
What does length(%HASH) produce if you have thirty-seven random keys in a newly created hash?How do I do < fill-in-the-blank > for each element in an array?