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

Purpose of $$ in subroutine

Thread Next
From:
Dave Tang
Date:
August 4, 2009 16:30
Subject:
Purpose of $$ in subroutine
Message ID:
op.ux5vkiuv8cr96e@imb09-02635.imbpc.ad
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  
subroutines:

                 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,

Dave

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About