Re: Meaning of [@tempArray]

[email protected] ("Rodrick Brown")
Newsgroups perl.beginners
Message-ID <[email protected]>
On Thu, Jun 12, 2008 at 5:28 AM, [email protected] <[email protected]>
wrote:

> Hi there,
>
> I am stuck with something here.
> What does the following piece of code mean?
>
> my @temp1;
> my @temp2;
> $cnt=0;
> $temp2[$cnt] = [@temp1];
>
> What is the kind of data stored in $tempFieldNames[$information] ?
>

Your creating a reference to an array as and storing that reference in array
index 0.
Data::Dumper can be very helpful for understanding what's going on here its
no different than doing saying $temp2[$cnt]  = \@temp1;

#!/usr/bin/perl -w
use strict;
use Data::Dumper;

my @temp1 = ("Apple", "Orange", "Mango");
my @temp2;

my $cnt=0;

$temp2[$cnt] = [@temp1];

print Dumper(\@temp2);

$VAR1 = [
          [
            'Apple',
            'Orange',
            'Mango'
          ]
        ];

As you can see here the first element index 0 in your array contains an
anonymous array.
I hope this is clear.

>
> Please help.
>
> Sundeep
>
>
> --
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> http://learn.perl.org/
>
>
>


-- 
[ Rodrick R. Brown ]
http://www.rodrickbrown.com http://www.linkedin.com/in/rodrickbrown
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.