Is there any significant differences between the two in terms of performance or memory usage?
If @list is big, yes. The latter makes a copy, which takes time, and uses about twice the amount of memory, half of which is available for reuse since @list goes out of scope.
Are there any potentially adverse consequences of holding on to references to static variables?The closest thing Perl has to static variable are "state" variables (new in 5.10). Your codes doesn't have any.
Returning references may have the danger that something else is also holding some reference to it. And he who has the reference has the power to modify it. If there's nothing else holding a reference, there's little danger.
In reply to Re: returning ref to static var vs. copying
by JavaFan
in thread returning ref to static var vs. copying
by perl5ever
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |