Paul Kraus wrote:
>
> Ok a couple questions on Ref from pg 251 programming Perl.
>
> push @$arrrayref,$filename);
> $$arrayref[0]="January";
> @$arrayref[4..6]=qw/May June July/;
>
> So this is actually creating an anonymous array that it then references
> correct?
> so the assignments January ect are being made to an anonymous array.
No, an anonymous array is delimited by [ and ]. That is creating an
actual array that is only accessible through an array reference.
my $ref = [ 1, 2, 3, 4, 5 ];
^^^^^^^^^^^^^^^^^
anonymous array
> This is cool but maybe I am missing the point. Why would you use these
> references rather then just using the actual variable?
> If some one could give me some real world applications for this I would
> be most appreciative.
A reference is a scalar so it is a lot easier to pass around between
subroutines then the entire array contents. You have to remember though
that modifying something through a reference will modify the original.
> I have seen them used to simulate a multidimensional array as well has
> hash and that makes sense. But beyond that I am kind of at a loss.
If you are used to data structures in other languages then you may find
Perl's data structures pretty limited (I know I did :-).) However
Perl's other features more then make up for this.
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]