in reply to Re: Matching nested parens
in thread Matching nested parens
Note that there is no need to track stack depth independently in Perl if you use an array as your stack with the push and pop builtins: Perl will keep track of the array length, which is accessible either by using the array in scalar context or with the $# sigil. There is an important difference: scalar @array gives the number of elements in @array (0 if @array is empty, 1 if there is one element) while $#array gives the highest index in @array (-1 if @array is empty, 0 if there is one element).
|
|---|