in reply to Perl 6 strings, interpolation and templates?

You can already do that in Perl 5:
say "Hello @{[ join(', ', @names) ]} how are you?";

There's no security issue because it's not say that causes the interpolation, it's the string literal. And it's no more possible for someone to provide a string literal as they could provide a for loop.

use strict; use warnings; use 5.010; my @names = qw( ikegami ); say "Hello @{[ join(', ', @names) ]} how are you?"; my $user_input = q{Hello @{[ join(', ', @names) ]} how are you?}; say $user_input;
Hello ikegami how are you? Hello @{[ join(', ', @names) ]} how are you?

Replies are listed 'Best First'.
Re^2: Perl 6 strings, interpolation and templates?
by BerntB (Deacon) on Mar 15, 2009 at 00:46 UTC

    Ah yes, 5.10... version limitations at work means that I've not read the perldoc for it yet. :-(

    Thanks. Sorry for stupid q.

      It's just the say that's 5.10 specific here... the interpolation mechanism already worked like this before...

      (This is just array interpolation with an anonymous array — in between the [...] can go arbitrary code.)

        This is embarrassing, how could I have missed that?! (Camel book etc are@work. Seems to have left my brain there too.)