Category Archives: references

Use scalar references to pass large data without copying.

References aren’t just for data structures, and many people overlook the benefit of references to simple scalars. With references to arrays and hashes you can keep those data structures in tact when you pass them to or return them from subroutines (Item 46: Pass references instead of copies). You don’t need to worry about scalar [...]

Make deep copies

When you want to make a copy of a hash or an array, it’s not enough to merely assign it to a new variable name, at least in the general case: my @copy = @original; This is a bad habit that new Perl programmers pick up because they are only dealing with flat arrays: that [...]