Re: Meaning of [@tempArray]



On Thu, Jun 12, 2008 at 5:28 AM, sundeep.sn@xxxxxxxxx <sundeep.sn@xxxxxxxxx>
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: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
http://learn.perl.org/





--
[ Rodrick R. Brown ]
http://www.rodrickbrown.com http://www.linkedin.com/in/rodrickbrown


Relevant Pages

  • Re: VB-101: Passing Arrays ByVal vs ByRef
    ... changed if an array is passed by Val. ... ' new reference ... As each function creates a new array object, ... 'secondArray' and 'secondArrayCopy'. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Need help with textboxes
    ... The JavaScript 1.5 Reference already states: ... All forms and their children are stored in an array ... use dot notation or object literals. ... No. Bracket property accessors allow their argument to be any string value. ...
    (comp.lang.javascript)
  • Re: Garbage Collection Issues in long-standing services
    ... the pinned array should get unpinned or ... The receive case is done quite well, I do create a 4K buffer and reuse it ... and remove the reference to my wrapper socket class, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to give selective access to the methods in a class?
    ... different memory locations at different times. ... The reference still leads to the ... So array resizing ... program pushes certain objects into the circular buffer, ...
    (comp.lang.java.programmer)
  • Re: Perlish map() function
    ... the reference material, the Array constructor was introduced in JavaScript ... evaluation would result in a ReferenceError. ... identifier shows that it is true. ...
    (comp.lang.javascript)