What is the meaning of double "at" (@@) in Perl?

I am looking at the proposed patch supplied by the supplier for the Perl tool we are using, and I am struggling to determine the reason for a certain type of change - a preliminary request "@" for the parameters passed to the subroutine.

For example, a string that was:

my ($genfd) = @_; 

Now:

 my ($genfd) = @@_; 

Not being a Perl developer, I'm studying here, but so far I understand that the '@_' are the parameters provided by the attached routine.

I also understand the purpose above (where "$ genfd" is enclosed in parentheses on the left) leads to "@_" in the list and then assign the scalar variable 'genfd' to the first element of this list. This should result in the first subroutine parameter being stored in 'genfd'.

That I'm completely stuck is what the second "@" does. I found examples of this use on GitHub , but never with an explanation, and cannot find an explanation on any Perl links or SO. Any help would be greatly appreciated.

+8
variables syntax perl
source share
1 answer

Sounds like a bad patch.

@@_ is a syntax error. At least when I have the following Perl source file:

 #!/usr/bin/perl use strict; use warnings; sub foo { my ($genfd) = @@_; } 

running perl -cw on it (with Perl 5.14.2) gives:

 Bareword found where operator expected at tmp.pl line 7, near "@@_" (Missing operator before _?) syntax error at tmp.pl line 7, near "@@_" tmp.pl had compilation errors. 

I did not consider all the examples on GitHub, but many of them are in files with a suffix ,v . This suffix is ​​used by RCS and CVS for their internal version control files. I think the @ symbol has some special meaning, so it doubles to indicate the @ symbol. (Yes, it’s a little strange to have internal RCS or CVS files in the Git repository.)

Some RCS or CVS interaction is the most likely explanation for the error, but there may be other reasons.

You should ask the person who provided the patch.

+18
source share

All Articles