The way to avoid that problem when you know you are dealing with large scalars, (arrays and hashes too), is to use pass by reference. Either:
sub frobnicate { $_[0] =~ s/foo/bar/g; return; }
Or:
sub frobnicate { my ($ref) = @_; $$ref =~ s/foo/bar/g; return; }
Either way you avoid a lot of copying and the lingering redundant memory usage.
In reply to Re^6: out of memory problem
by BrowserUk
in thread out of memory problem
by lightoverhead
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |