You're replying to a comment by Dodger.

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>
<html>
  <head>
    <title>Your arguments</title>
  </head>
  <body>
    <dl>
@{[map {<<"EOF2"} $cgi->param]}
      <dt>$_</dt>
      <dd>@{[$cgi->param($_)]}</dd>
EOF2
    </dl>
  </body>
</html>
EOF

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

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

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