Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
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 (Deacon) 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 lurking in the Monastery: (22)
As of 2014-12-18 14:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (54 votes), past polls