NetWallah has asked for the wisdom of the Perl Monks concerning the following question:
where the UA attribute points to an LWP::UserAgent object.sub sub_name{ my ($self, %att) = @_; # $att{METHOD} or die "ERROR: Method not specified"; my $url = $self->{URL}; my $methodref = $self->{UA}->can ($att{METHOD}) or die "ERROR: No such METHOD: $att{METHOD}"; $self->{RESPONSE} = $methodref->( $self->{UA}, $url , ($att{VALUE}? ('Content' => to_json( +$att{VALUE})) : ()) ); ... }
I feel that the "$methodref->( $self->{UA}.. " syntax is a little ugly/unnatural, and there "should" be a more OO style syntax to achieve this. Any thoughts ?
Update:Formatted code.
Software efficiency halves every 18 months, thus compensating for Moore's Law.
|
|---|