in reply to Re: sprintf: using nested code
in thread sprintf: using nested code
Of course, you can solve the problem by calling the coderef:$ perl -e 'print sprintf( "%s%s", > "header" . "\n", > sub { return 3}); > ' header CODE(0x6000684c8)
as shown by BrowserUk, but it seems to me that you are looking for complicated ways of achieving simple things.$ perl -e 'print sprintf( "%s%s", "header" . "\n", ,sub { return 3}- +>())' header 3
Why don't you define your sub separately? Or use some other way of merging your data?
Something like that works properly:
$ perl -e 'sub concat { my $str; for ($_[0]..$_[1]) { $str .= $_;} $st +r;} > print sprintf "%s\n%s\n", "foo", concat('a', 'e'); > ' foo abcde
|
|---|