in reply to Re: Re: How does ~~ force string interpolation of code into scalar context?
in thread How does ~~ force string interpolation of code into scalar context?

I think these CAN be useful ... for decorative purposes ...

$arg1 = "arg1"; $arg2 = "arg2"; $arg3 = "arg3"; sub f1 { return "1"; } sub f2 { return "0"; } sub f3 { return "3"; } print "${\-+- f1( $arg1 )}"; print "${\+-+ f2( $arg2 )}"; print "${\-+- f3( $arg3 )}"; print "\n"

isn't that far better than the undecorated print statements? ( Same f1(), f2(), f3(), $arg1, $arg2, $arg3. )

print f1( $arg1 ); print f2( $arg2 ); print f3( $arg3 );

And FAR superior to the boring and mundane:

print "103\n";

--
TTTATCGGTCGTTATATAGATGTTTGCA

Replies are listed 'Best First'.
Re: Re: Re: Re: How does ~~ force string interpolation of code into scalar context?
by davido (Cardinal) on Oct 27, 2003 at 01:01 UTC
    Far better indeed, as your "undecorated print statements" don't interpolate the function f1, f2 and f3; they just print the literal text f1( ... ).

    The "decorative" version executes f1() with $arg1 as its parameter.

    Of course neither approach is better than print "@{[f1( $arg1 )]}";, and that method is, itself, usually worse than print f1( $arg1 ); (without unnecessary interpolation).


    Dave


    "If I had my life to live over again, I'd be a plumber." -- Albert Einstein