in reply to passing paramters to a sub
First off, you are passing a hash, but calling it list so the example below uses a list (array).
use strict; use warnings; my @list = (1, 2, 3, 4); my $value = 10; whatever (\@list, $value); sub whatever { my @localList = @{$_[0]}; #Deref first (reference) param my $localValue = $_[1]; print join ", ", @localList; print " - $localValue"; }
You need to pass the array as a reference because otherwise it will be flattened, which is not what you want.
|
|---|