in reply to Re^2: my and scope
in thread my, scope, and references

Being able to return a reference safely is fundamental to Perl, and doesn't raise any style-police eyebrows. Consider DBI, where database rows are fetched as an array-ref or hash-ref. Consider JSON, where the thawed JSON data is returned as a reference to a Perl data structure.

Since you have a C++ background, you might appreciate that Perl references are somewhat analogous to C++11's std::shared_ptr; usually safe to return, because they are referenced counted, and safe to let fall out of scope, because the reference counting also handles destruction.


Dave