*nix shells such as sh, csh, tcsh, bash, etc. store their PID in $$.
perl, borrowing from Unix (as it is wont to do), also stores its PID in the $$ variable. However, this is not $$'s only use in perl. It also is used when resolving a reference to a scalar. It can be used to resolve a reference to an array or hash, but the -> notation is more common. Also, please use your references intelligently and only when necessary. Nobody wants to see 'print "$$$$$my_ref"' in the code s/he inherits.
# Hello, World! in perl with a reference
$greeting = 'Hello, World!';
$ref = \$greeting;
# Hello, World! in perl with a referenced array
@greeting = ('Hello,', 'World!');
$ref = \@greeting;
print "$$ref $ref->\n";
Outside the realm of computer programming, $$ is used to denote double dollars,the currency of Yasuhiro Nightow's manga cum anime, Trigun.
Log in or register to write something here or to contact authors.
Need help? email@example.com