What is the '@(' doing in this Perl code?

Posted by Anthony Veckey on Stack Overflow See other posts from Stack Overflow or by Anthony Veckey
Published on 2011-11-22T01:05:02Z Indexed on 2011/11/22 1:50 UTC
Read the original article Hit count: 186

Filed under:
|

In this code snippet:

    use strict;
    use warnings;
    use Data::Dumper;
    my $r = [qw(testing this thing)];

    print Dumper($r);
    foreach my $row (@({$r})
    {
        print "$row\n";
        $row .= 'mod';
    }
    print Dumper($r);
    print Dumper(@({$r});

I figured out that the '(' after the '@' in the foreach is causing this not to loop correctly. I have no idea why this code even works as there is no ending parenthesis. What is this doing? It looks to be creating a new variable on the fly, but shouldn't 'use strict' have fired or something?

Please help explain what that '@(' is doing and why it still runs without an ending parenthesis.

© Stack Overflow or respective owner

Related posts about perl

Related posts about variable-declaration