in reply to How to use @EXPORT

If I understand you correctly, you are asking why would someone pass an array or hash reference to a subroutine.

There are two reasons I can think of immediately: passing multiple distinct arrays/hashes to a subroutine and passing an array or hash that you want to manipulate in the subroutine.

If you pass multiple arrays into a subroutine, there's no way to distinguish where one ends and the next begins. That's why you would pass them as references.

If your subroutine adds or removes elements from the hash or array and you want that to be reflected when the subroutine ends, you must pass by reference.

Edit: Here's some code to show what I mean.

#!/usr/bin/perl use warnings; use strict; my @a = qw( a1 a2 a3 ); my @b = qw( b1 b2 b3 ); my %c = ( a=>1, b=>2 ); my %d = ( c=>3, d=>4 ); sub multi_flat { # my ( @foo1, @foo2 ) = what should go here? # my ( @foo1, @foo2 ) = ( shift, shift ) ? # my ( @foo1, @foo2 ) = ( $_[0], $_[1] ) ? my @foo = @_; #this flattens the arrays into one print join( ", ", @foo), "\n"; } multi_flat( @a, @b ); #prints "a1, a2, a3, b1, b2, b3" multi_flat( %c, %d ); #prints "a, 1, b, 2, c, 3, d, 4" sub multi_fixed_arr { my ( $arr1, $arr2 ) = @_; print "\$arr1 is ", join( ", ", @$arr1), "\n"; print "\$arr2 is ", join( ", ", @$arr2), "\n"; } sub multi_fixed_hash { my ( $hash1, $hash2 ) = @_; print "keys \$hash1 is ", join( ", ", keys %$hash1), "\n"; print "keys \$hash2 is ", join( ", ", keys %$hash2), "\n"; } multi_fixed_arr( \@a, \@b ); #prints: $foo1 is a1, a2, a3 # $foo2 is b1, b2, b3 multi_fixed_hash( \%c, \%d ); #prints: keys $foo1 is a, b # keys $foo2 is c, d sub pop_one { my @arr1 = @_; pop @arr1; } print join( ", ", @a), "\n"; #prints "a1, a2, a3" pop_one( @a ); print join( ", ", @a), "\n"; #prints "a1, a2, a3" sub pop_one_fixed { my $arr = shift; pop @$arr; } print join( ", ", @a), "\n"; #prints "a1, a2, a3" pop_one_fixed( \@a ); print join( ", ", @a), "\n"; #prints "a1, a2"