in reply to Re: Refactoring Perl 4 - Replace Temp with Query
in thread Refactoring Perl #4 - Replace Temp with Query
I don't usually use temp variables for that, but that's the idea, if you mean something like:
sub base_price{ my $self = shift; if ( not $self->{_base_price} ){ $self->{_base_price} = $self->{_quantity} * $self->{_item_price}; } return $self->{_base_price}; }
That's how I usually do result caching for methods. There are other options too, like Memoize, although I haven't tried any of the modules that do this.
perl -e 'split//,q{john hurl, pest caretaker}and(map{print @_[$_]}(joi +n(q{},map{sprintf(qq{%010u},$_)}(2**2*307*4993,5*101*641*5261,7*59*79 +*36997,13*17*71*45131,3**2*67*89*167*181))=~/\d{2}/g));'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Refactoring Perl 4 - Replace Temp with Query
by akho (Hermit) on Jul 27, 2007 at 18:45 UTC | |
by agianni (Hermit) on Jul 30, 2007 at 12:48 UTC |