Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Explaining small Code

by Grimy (Pilgrim)
on Sep 21, 2013 at 18:26 UTC ( #1055144=note: print w/ replies, xml ) Need Help??


in reply to Explaining small Code

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.


Comment on Re: Explaining small Code
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1055144]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2014-12-18 06:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (43 votes), past polls