in reply to RE: RE: RE: any-all
in thread any-all

1. What is a closure?

2. Writing $a is nicer (=shorter and more readable) than $_[0]

3. I'd like to iterate through both arrays, something like
"for $a=(@A), $b=(@B)" and thus the pop. Hopefuly perl just pops a pointer array to the original.

The goal is a short and compact sub that will do the above.

Replies are listed 'Best First'.
RE: (5) any-all
by Adam (Vicar) on Sep 02, 2000 at 03:15 UTC
    1. A closure is a sub-routine that generates and returns a subroutine. They are good for playing games with memory and scope. See my Base Conversion Utility for a good example.

    2. Writing $a may be nicer then $_[0] but its also more error prone and not properly scoped. $a and $b are also magic variables reserved for sort.

    3. Perl does not 'pop a pointer'. It dereferences the array and pops the last value off of it.

    Also, I think it is easier to read "while( @A and @B ){ dofunc( pop(@A), pop(@B) ) }" As this keeps you from poping @A until you know that @B still has values.