in reply to Create string with a delay

This is easy. Use Data::Postponed. I wrote this module to handle just this kind of task.

use Data::Postponed 'postpone_forever'; $a = ''; $str = postpone_forever( "blabla" . $a . "blabla" ); $a = "XXX"; print "$str\n"; # prints blablaXXXblabla

[Edit. I originally goofed by using $x instead of $a. Sorry. That typo is gone now. I also made the string "$blabla${a}blala" nicer to read.]

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Replies are listed 'Best First'.
Re^2: Create string with a delay
by Anonymous Monk on Jun 14, 2006 at 20:14 UTC
    Surely, that module isn't capable of reversing the concatenation of its arguments, and then performing it again, is it? Perhaps you meant something more like this:
    $a = ''; $str = "blabla" . postpone_forever( $a ) . "blabla"; $a = "XXX"; print "$str\n";

      Oh, yeah, you're right. $a = postpone_forever( '' ) would have been ok as well as $str = postpone_forever( "blabla" ); $str .= $a; $str .= "blabla";. Anything like that would be ok.

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊