in reply to Help w passing array by ref
is very misleading. All it does is create a one element array @xpid, whose only element is a reference to the original array. It's better to write the first line as:my @xpid = shift;
my $xpid_ref = shift;
Then, to deference a reference (to get to its juicy content), you place the appropriate sigil in front of the reference (or the block that results in the reference). So, your loop would start with:
Furthermore, if you are looping over an array withforeach my $item (@$xpid_ref) {
don't use an index to get to the element! You already have it in your variant: $element. So, you'd write your loop as:foreach my $element (@array)
Of course, the entire function body can be reduced to a one-liner:foreach my $item (@$xpid_ref) { $return .= $item; }
and then you can take the 'return' off as well.return join "" => @{+shift}
Abigail
|
|---|