Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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.

by choroba (Abbot)
on Mar 25, 2013 at 23:26 UTC ( #1025412=note: print w/ replies, xml ) Need Help??


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
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 (Chaplain) 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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1025412]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (12)
As of 2014-07-28 16:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (204 votes), past polls