I'm just trying to confirm that I understand someone's code correctly.
If someone has code that says:
$foo ||= mysub();
I'm assuming that it means if $foo is nothing or undef, then assign it some value via mysub(). If I'm wrong on this, please let me know.
Also, what's the difference between this:
$somescalar = [['one','two'],['three','four']];
and this:
@myarray = (['one','two'],['three','four']);
I'm assuming they both do the same thing and create a new list of lists in memory. The first one is a reference to the list of lists while the other is the actual list(array) of lists itself. If I'm wrong here, please let me know. I'm probably only 40-70 hours into perl. I've coded in other languages before, but syntax is usually the big hurdle for me.
As you can see first line of code resulted in one more "level" of reference. This is because it created single element array that it's only element is reference to array containing references to lower level arrays. In simple words, first code is not what you would usually want to use
The advantage of working with references is that when you are passing them through a function, you are just passing an address to memory, instead of copying the whole thing over (passing by value).
BTW, in defining the @myarray you are using the anonymous array construct also: ['one','two'] will yield a reference to an array containing 'one' and 'two'.