Data::Postponed::Forever - Recompute values as needed to use post facto changes to input variables
Example using postpone_forever()
use Data::Postpone 'postpone_forever'; %functions = ( foobar => 'foo' ); $code = "sub " . postpone_forever( $functions{foobar} ) . " { return time }"; $functions{foobar} = "baz"; # Reflects the new name of 'bar' instead of 'foo'; print $code; # Continues to reflect changes to the input variables $functions{foobar} = "quux"; print $code;
Example using the OO
use Data::Postponed; %functions = ( foobar => 'foo' ); $code = "sub " . Data::Postponed::Forever->new( $functions{foobar} ) . " { return time }"; $functions{foobar} = "baz"; # Reflects the new name of 'bar' instead of 'foo'; print $code; # Continues to reflect changes to the input variables $functions{foobar} = "quux"; print $code;
The value of expressions that have had postpone_forever called on them always reflect the current value of their input variables.
Returns a new overloaded object bound to whatever was passed in as the EXPR.
None. This is raw Data::Postponed.
the Data::Postponed manpage, the Data::Postponed::OnceOnly manpage, the Data::Postponed::Once manpage, the overload manpage
This is pretty near identical to the "Really symbolic calculator" mentioned in the overload manpage.
This is also really just Yet Another Templating Engine in
disguise. Corion pointed this out to me. If you have a value which
always results in the value of "Hello $firstname, ... Regards,
$sender" you could certainly just change the value of $firstname as
needed and thus generate template driven strings.
Joshua ben Jore, <jjore@cpan.org>
Please report any bugs or feature requests to
bug-data-postponed@rt.cpan.org, or through the web interface at
http://rt.cpan.org/NoAuth/ReportBug.html. I
will be notified, and then you'll automatically be notified of
progress on your bug as I make changes.
Corion of perlmonks.org
Copyright 2005 Joshua ben Jore, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.