You're viewing a comment by Dodger and its responses.

Dodger Permalink
May 14, 2014, 23:55

The syntax you're calling a "turtle" operator is actually pretty simple. It places the contents into an anonymous arrayref and then dereferences it into an array (which is thus interpolated into the quoted string, if used that way).

You can use it much like you use your "goatse operator" as well: $num_items = @{[qw(foo bar baz)]}.

But it's way more useful for something you didn't even mention: doing just about anything in the middle of double quoted strings.

For instance, call a function or method. Process a map against an array. Stuff like that.

It's especially useful in the middle of here-documents you don't want to break out of for formatting reasons like keeping a block of HTML looking clean.

For instance:

use CGI();
my $cgi = new CGI;
print <<"EOF";
<!doctype html>
    <title>Your arguments</title>
@{[map {<<"EOF2"} $cgi->param]}

Comment Responses

Dodger Permalink
May 14, 2014, 23:56

You apparently allow some HTML in your comments or something. My example got hosed and I'm not going to try to figure out what you're letting through and what you're breaking, and I'm not going to rewrite the whole thing with & lt ; entities so I hope you can figure out what was meant.

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "0day_173": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.