in reply to Reference to a non-primitive (e.g. hash) local function variable is returned to the caller
Short: It's possible and legal.
It's non best-practice programming for languages like C, C++, etc.
where returning pointer to object from the stack is an error. But this is
Perl and Perl usually keeps track of the variables in use (ref-counts)
and garbage collects them when necessary.
There are edge-cases with cyclic dependencies though (see: weaken in Scalar::Util).
|
---|
In Section
Seekers of Perl Wisdom