Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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 (Bishop)
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

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 (Curate) 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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2017-11-19 18:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (282 votes). Check out past polls.

    Notices?