Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: How would you simplify this code?

by ikegami (Patriarch)
on Apr 07, 2011 at 06:28 UTC ( [id://897947]=note: print w/replies, xml ) Need Help??


in reply to How would you simplify this code?

sub remote_run { my ($self, %args) = @_; $self->resource( $args{resource} ) if $args{resource}; $self->username( $args{username} ) if $args{username}; my $resource = $self->resource or die("'resource' must be provided"); my $username = $self->username or die("'username' must be provided"); # Here comes the actual code ... }

Sure, you could use a loop, but I think it would reduce readability even though it would remove some redundancy.

This usage is rather odd, which is why there's no clear winning way of doing it. I'd use args or attributes, not this mixture.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-25 12:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found