Search⌘ K

Introduction to References

Explore Perl references and their role in passing values to functions without copying data. Understand how references allow you to update values in place, enabling more efficient and maintainable code handling complex data structures like hashes and arrays.

We'll cover the following...

Pass values to functions

Perl usually does what we expect, even if what we expect is subtle. Consider what happens when we pass values to functions:

Perl
sub reverse_greeting {
my $name = reverse shift;
return "Hello, $name!";
}
my $name = 'Chuck';
say reverse_greeting($name);
say $name;

Outside the function, $name contains Chuck, even though the value ...