in reply to Total Syntax Confusion Plus

  1. It returns a reference to the following variable. perlop
  2. They operate on the array referenced by the scalar. Dereferencing Syntax, References Quick Reference, perlref, perlreftut
  3. After the first call returns.

Replies are listed 'Best First'.
Re^2: Total Syntax Confusion Plus
by RobertJ (Acolyte) on Apr 20, 2009 at 18:12 UTC

    "1. It returns a reference to the following variable". I read the reference and understand; now I need to think of what it means in the program.

    "2. They operate on the array referenced by the scalar". Again read your reference and have concluded I need to read more about the use of references.

    "3. After the first call returns". In thinking about this I believe what is happening is like "nesting". I have been going through this using a single IP range and printing to try to understand. After reading more on the use of references will continue that effort.

    Thanks, will likely be back

      now I need to think of what it means in the program.

      You can't pass arrays to a sub. The only thing that can be passed to a sub is a list of scalars. The solution is to pass references to arrays, references being scalars.

      In thinking about this I believe what is happening is like "nesting".

      I didn't look at how recursion is used here, but it's usually used to divide and conquer. Let's take merge sort, for example.

      Sorting

      +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
      is done by sorting
      +---+---+---+---+---+---+---+---+-------------------------------+ | | | | | | | | | | +---+---+---+---+---+---+---+---+-------------------------------+
      and
      +-------------------------------+---+---+---+---+---+---+---+---+ | | | | | | | | | | +-------------------------------+---+---+---+---+---+---+---+---+

      independently then merging the results. How does it sort the two halves? Well by breaking each down into two halves and sorting those. Etc.