in reply to Re: How does ~~ force string interpolation of code into scalar context?
in thread How does ~~ force string interpolation of code into scalar context?
Thanks for pointing out a new idiom for me (which may not be all that necessary but is definately interesting to understand).
In the spirit of exploration I found that the following will also at least compile and force scalar context. Some of them will mangle return values though. ;)
sub context { print wantarray ? "List\n" : "Scalar\n"; } my $string; $string = "Test ${\~~context()} string"; $string = "Test ${\!!context()} string"; $string = "Test ${\+-+context()} string"; $string = "Test ${\-+-context()} string"; $string = "Test ${\&\&context()} string";
Thanks again...
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: How does ~~ force string interpolation of code into scalar context?
by sauoq (Abbot) on Oct 25, 2003 at 22:05 UTC | |
|
Re: Re: Re: How does ~~ force string interpolation of code into scalar context?
by TomDLux (Vicar) on Oct 27, 2003 at 00:54 UTC | |
by davido (Cardinal) on Oct 27, 2003 at 01:01 UTC |