develooper Front page | perl.beginners | Postings from August 2009

Purpose of $$ in subroutine

Thread Next
Dave Tang
August 4, 2009 16:30
Purpose of $$ in subroutine
Message ID:
Hi everybody,

I was reading perlfaq7.pod, 7.15: How can I pass/return a {Function,  
FileHandle, Array, Hash, Method, Regex}?

In one of the examples it shows how regular expressions can be passed to  

                 sub compare($$) {

                    my ($val1, $regex) = @_;
                    my $retval = $val1 =~ /$regex/;
                    return $retval;


                 $match = compare("old McDonald", qr/d.*D/i);

I know the special variable $$ contains the process number of the Perl  
running this script, but just wanted to know its purpose in compare($$).

Many thanks,


Using Opera's revolutionary e-mail client:

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About