madM has asked for the
wisdom of the Perl Monks concerning the following question:

Hi!
i just wanted to know what happens when you use the split operator without nothing and why it´s needed to dereference \@numbers(this code reads a file with a matrix and builds it in the @matrix array)
Thanks!

\@numbers is not de-referencing but is creating a reference to the array @numbers. So @matrix will be an array of array references. Without it, the push would push all individual elements of @numbers onto @matrix, effectively creating a long one-dimensional list instead of a matrix.

RTFM - the use of perldoc -f split will provide the answer to your first question ... and indeed, to a degree, your second question...

push() pushes all its' args onto the array given as the first arg, so you need to dereference the numbers array iff the required end result is a n array of arrays i.e. without the de-ref, all you do is flatten out the list so numbers will end up containing a list of the elements of numbers.

In the cold light of day, I realise that some of the above response is, at the very least, misleading - instead of '...need to dereference...', I should have said '...create a reference to...'.

You seem to be confused about vocabulary. \@numbers takes a reference to @numbers, which is the opposite of “dereferencing“.

It is needed because the natural representation for a matrix is an array of arrays. Since a perl array can only hold scalar values, arrays of arrays are actually arrays of references to arrays. PerlLoL goes into a lot more detail about this concept.

Without the backslash, all numbers would be squashed together inside @matrix without structure. The result would effectively be a list, not a matrix.

The question about split is easy to answer by looking at the doc. Without any argument, split splits $_ on whitespace. It is equivalent to split /\s+/, except that leading whitespace in $_ is ignored.