Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Perl 6 strings, interpolation and templates?

by ikegami (Patriarch)
on Mar 15, 2009 at 00:33 UTC ( [id://750687]=note: print w/replies, xml ) Need Help??


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.)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://750687]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2026-04-18 07:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.