Re: Purpose of $$ in subroutine

2009-08-05 Thread Chas. Owens
On Wed, Aug 5, 2009 at 05:21, Dermot wrote: > 2009/8/5 Chas. Owens : >> On Tue, Aug 4, 2009 at 23:07, Dave Tang wrote: >>> On Wed, 05 Aug 2009 12:55:22 +1000, Chas. Owens >>> wrote: >>> >>> snip > > Here's someone's recent experience of encountering prototypes: > > http://perlhacks.com/2009/06/wha

Re: Purpose of $$ in subroutine

2009-08-05 Thread Dermot
2009/8/5 Chas. Owens : > On Tue, Aug 4, 2009 at 23:07, Dave Tang wrote: >> On Wed, 05 Aug 2009 12:55:22 +1000, Chas. Owens >> wrote: >> >> snip Here's someone's recent experience of encountering prototypes: http://perlhacks.com/2009/06/what-is-wrong-with-this-picture.php Good luck, Dp. -- To

Re: Purpose of $$ in subroutine

2009-08-04 Thread Chas. Owens
On Tue, Aug 4, 2009 at 23:07, Dave Tang wrote: > On Wed, 05 Aug 2009 12:55:22 +1000, Chas. Owens > wrote: > > snip >> >> In this case it is telling Perl that compare expects two scalars as >> arguments. > > snip > > Now the compare($$) makes much more sense. > > snip >> >> There are many [pitfalls

Re: Purpose of $$ in subroutine

2009-08-04 Thread Dave Tang
On Wed, 05 Aug 2009 12:55:22 +1000, Chas. Owens wrote: snip In this case it is telling Perl that compare expects two scalars as arguments. snip Now the compare($$) makes much more sense. snip There are many [pitfalls][2] to prototypes and they should really not be used unless you have a

Re: Purpose of $$ in subroutine

2009-08-04 Thread Chas. Owens
On Tue, Aug 4, 2009 at 19:30, Dave Tang wrote: snip >                sub compare($$) { snip > running this script, but just wanted to know its purpose in compare($$). snip Those are [prototypes][1]. They change how Perl thinks about the function call. In this case it is telling Perl that compare

Re: Purpose of $$ in subroutine

2009-08-04 Thread John W. Krahn
Dave Tang wrote: Hi everybody, Hello, 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($$) {

Purpose of $$ in subroutine

2009-08-04 Thread Dave Tang
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) = @_;