• *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.

    #!/usr/bin/perl
    # Hello, World! in perl with a reference
    $greeting = 'Hello, World!';
    $ref = \$greeting;
    print "$$ref\n";
    
    #!/usr/bin/perl
    # Hello, World! in perl with a referenced array
    @greeting = ('Hello,', 'World!');
    $ref = \@greeting;
    print "$$ref[0] $ref->[1]\n";

  • Outside the realm of computer programming, $$ is used to denote double dollars,the currency of Yasuhiro Nightow's manga cum anime, Trigun.

Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.