Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do @$ and $$ mean in Perl?

OK, so two questions on odd syntax. I am working on some older Perl code that needs modification, and I came across the following line:

@$tmp=split(/,/,$tmpVals);

I have no idea how to read this, it looks like the RHS is splitting the variable string on , so that's fine, but it is the left hand side I am thrown by. What in the world is @$, as far as a I know it isn't a default variable. DOes anyone know its significance?

And then there is $$, which I have read normally represent the Perl PID. However, in this case it comes right before a veriable/assignment statement. Does it have a related effect there?

$$tmp=$row[1];

Thanks in advance.

like image 828
Brian Avatar asked Jun 15 '11 20:06

Brian


1 Answers

What you're looking at are not special perl variables, but instances of references. They're described in perlref.

These are symbolic references: If $tmp contains "myvar", then the variable @myvar will be assigned to. The same applies to the second example.

like image 178
Michael Lowman Avatar answered Oct 23 '22 10:10

Michael Lowman