in reply to Re^2: I'm stuck adding more named parameters to a subroutine since the new named parameters might have the same name as the current ones.
in thread I'm stuck adding more named parameters to a subroutine since the new named parameters might have the same name as the current ones.

You are creating an unnecessary copy. You can
retrun \@attributes;
as well, the reference will be different each time as you are using my inside the sub.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
  • Comment on Re^3: I'm stuck adding more named parameters to a subroutine since the new named parameters might have the same name as the current ones.
  • Download Code

Replies are listed 'Best First'.
Re^4: I'm stuck adding more named parameters to a subroutine since the new named parameters might have the same name as the current ones.
by Lady_Aleena (Priest) on Mar 25, 2013 at 23:37 UTC

    I decided to take it one step further along. :)

    sub get_attributes { my ($options, $valid) = @_; my @attributes; for (@{$valid}) { my $value = $options->{$_}; push @attributes, qq($_="$value") if $options->{$_}; } return join(' ',('',@attributes)); }

    Instead of joining them later, I just joined them in the subroutine.

    Have a cookie and a very nice day!
    Lady Aleena