in reply to Re: Re: Can you take a slice of an array reference?
in thread Can you take a slice of an array reference?
that $a is now a reference to an array and, syntatically, it can be used as a stand-in for an array name. Now knowing this, treat @{$a} as you would @foo and get the same results:$a=\@foo;
It's just a teaching tool, and I've used it before with great success. And when they're confortable with this you can remove the braces (reminding them of precedence) and when they've got that down pat, show them -> where they get a dereference for free.@{$a}; # Same as @foo ${$a}[1]; # Same as $foo[1] @{$a}[0..2]; # Same as @foo[0..2]
|
|---|