array of arrays

Hi. =20

Im using a multidimensional array in the following way:

$array[$i][$j][$k] =3D [ @list ];   where, @list is a 2-D array ie. =
$list[][].

How do I access the individual elements of the array @list once Ive put it =
into the array @array?

Thanks.

-ty

0
tcruickshank
10/18/2001 8:28:41 PM
perl.beginners 29360 articles. 3 followers. Follow

6 Replies
855 Views

Similar Articles

[PageSpeed] 49

On Thu, Oct 18, 2001 at 02:28:41PM -0600, Tyler Cruickshank wrote:
> $array[$i][$j][$k] = [ @list ];   where, @list is a 2-D array ie. $list[][].
> 
> How do I access the individual elements of the array @list once Ive put it
> into the array @array?

$array[$i][$j][$k][$l][$m] eq $list[$l][$m]

However, this is the first time I've seen someone intentionally using such a
large-dimension array.  What is this for?

 
Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--
0
michael
10/18/2001 9:21:34 PM
In article <20011018132134.C14451@shoebox.net>, michael@shoebox.net 
(Michael Fowler) wrote:

> $array[$i][$j][$k][$l][$m] eq $list[$l][$m]

> However, this is the first time I've seen someone intentionally using such a
> large-dimension array.  What is this for?

i've used many more dimensions than that ;)
-- 
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
0
comdog
10/18/2001 9:32:33 PM
>=20How=20do=20I=20read=20data=20out=20of=20a=20table-file=20in=20an=20arr=
ay-of-arrays?
>=20
>=20Problem:=20I=20have=20to=20compare=20two=20tables=20with=20pairs=20of=20=
start-stop-Positions.
>=20I=20want=20to=20find=20out,=20which=20pair=20of=20Start-Stop-Position=20=
in=20table_1=20>=20is=20
>=20entirely=20within=20the=20range=20marked=20by=20a=20pair=20of=20start-=
stop-positions=20of=20
>=20the=20second=20table.
>=202..5=20would=20be=20in=202..6=20or=201..7,=2045..46=20in=2023..47=20or=
=2040..46=20and=20so=20on.

Mornin,
how=20are=20you=20getting=20those=20ranges?=20From=20a=20database=20using=20=
the=20DBI=20module=20or=20from=20a=20text=20file=20etc?

________________________________________________________________________
This=20email=20has=20been=20scanned=20for=20all=20viruses=20by=20the=20Mes=
sageLabs=20Email
Security=20System.=20For=20more=20information=20on=20a=20proactive=20email=
=20security
service=20working=20around=20the=20clock,=20around=20the=20globe,=20visit
http://www.messagelabs.com
________________________________________________________________________
0
shardisty
10/20/2003 10:37:56 AM
.... from two text files.
Output of a pattern-searching-program and data out of a DB (genebank). 
No prob to read in those data in a textfile too.

Stephen Hardisty wrote:

>>How do I read data out of a table-file in an array-of-arrays?
>>
>>Problem: I have to compare two tables with pairs of start-stop-Positions.
>>I want to find out, which pair of Start-Stop-Position in table_1 > is 
>>entirely within the range marked by a pair of start-stop-positions of 
>>the second table.
>>2..5 would be in 2..6 or 1..7, 45..46 in 23..47 or 40..46 and so on.
>>
> 
> Mornin,
> how are you getting those ranges? From a database using the DBI module or from a text file etc?
> 
> ________________________________________________________________________
> This email has been scanned for all viruses by the MessageLabs Email
> Security System. For more information on a proactive email security
> service working around the clock, around the globe, visit
> http://www.messagelabs.com
> ________________________________________________________________________
> 
> 



0
janenerz
10/20/2003 10:50:26 AM
Alright=20then,
first=20you=20want=20to=20think=20about=20how=20you=20are=20going=20to=20p=
opulate=20the=20arrays.=20For=20example,=20if=20I=20have=20a=20file=20that=
=20contains=20the=20following=20data:
1|10
5|7

I=20would=20do=20this:

open(FH,=20"<=20bob.txt");

my=20@file_list;

while(<FH>)
{
=09#=20add=20a=20reference=20of=20the=202=20file=20columns=20to=20@file_li=
st
=09push(@file_list,=20[split(/\|/,=20$_)]);
}

-------------------

Doing=20the=20same=20thing=20with=20a=20database=20is=20a=20more=20content=
ious=20issue=20as=20there=20are=20many=20different=20ways=20to=20go=20abou=
t=20it,=20but=20I=20would=20do=20the=20following:

my=20$dbh=20=3D=20DBI->connect();=20#=20however=20you=20want=20to=20connec=
t=20to=20the=20database

my=20$sth=20=3D=20$dbh->prepare('SOME=20SQL=20HERE');
$sth->execute;=20#=20run=20the=20sql

my=20@db_list;

while($sth->fetchrow_arrayref)
{
=09#=20assuming=20you=20only=20select=202=20rows=20in=20your=20sql
=09push(@db_list,=20$_);
}

----------------

So=20now=20we=20have=202=20arrays=20of=20array=20references=20we=20need=20=
to=20compare=20them.=20Ofcourse,=20it=20would=20be=20much=20more=20efficie=
nt=20to=20do=20this=20within=20the=20second=20loop=20but=20for=20the=20sak=
e=20of=20simplicity=20we'll=20do=20this=20in=20another=20loop=20again:

foreach(@file_list)
{
=09my=20$file_start=20=3D=20$_->[0];
=09my=20$file_end=20=3D=20$_->[1];

=09foreach(@db_list)
=09{
=09=09my=20$db_start=20=3D=20$_->[0];
=09=09my=20$db_end=20=3D=20$_->[1];

=09=09#=20check=20to=20see=20whether=20the=202=20numbers=20taken=20from=20=
the
=09=09#=20file=20exist=20between=20the=202=20numbers=20taken=20from=20the
=09=09#=20database,=20this=20might=20not=20be=20what=20you=20want=20but=20=
you
=09=09#=20get=20the=20idea,=20right?
=09=09if(($file_start=20>=3D=20$db_start)=20&&
=09=09=09($file_end=20<=3D=20$db_end))
=09=09{
=09=09=09#=20do=20whatever=20you=20want=20to=20do=20with
=09=09=09#=20your=20matches=20here
=09=09}
=09}
}

Hope=20this=20send=20you=20along=20the=20right=20path,=20if=20not=20and=20=
you've=20read=20this=20far=20then=20I=20can=20only=20apologise.

Cheers!

________________________________________________________________________
This=20email=20has=20been=20scanned=20for=20all=20viruses=20by=20the=20Mes=
sageLabs=20Email
Security=20System.=20For=20more=20information=20on=20a=20proactive=20email=
=20security
service=20working=20around=20the=20clock,=20around=20the=20globe,=20visit
http://www.messagelabs.com
________________________________________________________________________
0
shardisty
10/20/2003 11:11:47 AM
The code you posted does not return any errors.
Check the parts you didn't post.



-----Original Message-----
From: Tommy Grav [mailto:tgrav@mac.com]=20
Sent: Tuesday, February 28, 2006 1:48 PM
To: beginners@perl.org
Cc: Tommy Grav
Subject: Array of arrays

I have a file of numbers that I want to read in and put the first 12 =20
lines into row one of
of a two-dimensional array, the next 12 into row two and so on.

	my $nref =3D 12 ;
	my $n =3D 0 ;
	my $im =3D 0 ;
	my @refstars ;
	my @refmag ;

	while (<>) {
	    my ($mag, $merr) =3D split ;

	    $refmag[$n] =3D $mag ;
	    $n++ ;
	    if($n=3D=3D$nref) {
	        $n =3D 0 ;
	        push @refstars, [@refmag] ;
	        $im++ ;
	    }
	}
	printf(" We have $im images with $nref reference stars \n") ;
	print $refstars[0][0] ;
	print $refstars[1][0] ;  # <- This is line 38

However this code returns an error I do not understand

	Missing right curly or square bracket at refstar.pl line 38, at
end =20
of line
	syntax error at refstar.pl line 38, at EOF
	Execution of refstar.pl aborted due to compilation errors.

Anyone know what I am doing wrong?

Cheers
Tommy


tgrav@mac.com
http://homepage.mac.com/tgrav/

"Any intelligent fool can make things bigger,
more complex, and more violent. It takes a
touch of genius -- and a lot of courage --
to move in the opposite direction"
                          -- Albert Einstein



0
tjohnson
2/28/2006 11:49:07 PM
Reply:

Similar Artilces:

Arrays, Arrays, Arrays
I mainly come from a JScript classic ASP background and I'm liking both C#.net and JScript.net. Now I have to say... "What's happened to arrays?" They used to be so flexible and easy to use. Here are my quick questions... Am I allowed to create an array with a non specified length so that I can add to it? If not then how can I modify an array's length? Can I create an array with a named index eg myArray["apple"] = "tasty"; or is the hash table the equivalent for this now? The classic array methods and properties like pop(), push(), length etc... are ...

How to unshift to an array in an array of arrays?
How to unshift to an array in an array of arrays? > -----Original Message----- > From: Angerstein [mailto:ang@nmc-m.dtag.de] > Sent: Wednesday, August 28, 2002 6:12 AM > To: beginners@perl.org > Subject: How to unshift to an array in an array of arrays? > > > How to unshift to an array in an array of arrays? $ perl -d -e 1 ..... DB<1> @aoa = ([qw(foo bar baz)]) << create array of arrays DB<2> x @aoa 0 ARRAY(0x80f82dc) 0 'foo' 1 'bar' 2 'baz' DB<3> unshift @{$aoa[0]}, 'qu...

referring to an array in an array of arrays
How can I get at an array in an array of arrays? I'm creating the arrays using: $fComments[$i++] = [ @comments ]; Now I want to get back what I put in: print "$fComments[0]\n"; but this prints ARRAY(0x107671f0). How do I follow that pointer? (I really think we need a pre-beginners list... =) TIA. - B You can try something like this: print "@{$fComments[0]}\n"; Which will attempt to dereference the array at $fComments[0]. -----Original Message----- From: Bryan R Harris [mailto:Bryan_R_Harris@raytheon.com] Sent: Tue...

Concatenating arrays from arrays of arrays
Hello - I am trying to accumulate items in a flat list (array) by concatenating on to it the scalars contained in arrays which in turn are contained in arrays. The data is to be read in from a file rather than existing as literals in my code. Everything I try either crashes the computer or gives me an array of arrays instead of a flat list. I have been programming in Unicon which has a concatenate operator, but Perl makes very heavy weather of nested list management. Should I switch to Lisp, or is there a way of doing what I want to do in Perl? Regards _John Sampson_ On...

Array of Arrays
Hi, I am looking for a way to create an array of arrays which needs to be passed to Oracle database to minimize the round trips to hte server. I was successful in sending simple arrays so far but no idea on how to create array of arrays in PB. I have used structures to simulate this but looks like I can't send the PB structure to Oracle. Anyone has any suggestions? Thanks, Anil PB 11 or 12 I believe will have this native. <Anil> wrote in message news:422789a4.721c.1681692777@sybase.com... > Hi, > > I am looking for a way to create an array of ar...

An array of arrays
Could anybody help me out here? Here's the message I just got from a guy I know: ----------- I was wondering if you know how to create and access an array of arrays in Perl. Basically I'm parsing an exported text file containing e-mails and I think I want to move some fields into arrays until I'm ready to do my report. Here basically is what I'm looking at doing: ^ | | Array 1 (messages) | | v <------ Array 2 -------> (message fields:FROM, TO, CC, etc, sensitivity, etc) I want to be able to search through the first array to count how many messag...

Array of Array.
How is possible to declare a DYNAMIC array of array ? I need something like a dynamic hash table whose pages grow up dynamically too (each one can have different number of elements). In other words, a matrix that can be dynamic in both dimension. example: [1,2,3...] [3,4..] [5] [6,7,8,9...] [.] .. .. .. Have you considered using a DataStore? -- <hopethishelps/> Roy Kiesler [TeamSybase] SDN CodeXchange -- http://codexchange.sybase.com "Marco Meoni - News" <mmeoni@usl4.toscana.it> wrote in message news:401ba036$1@forums-2-dub... > How ...

Array of arrays
Hi I'm trying to return from a web service a array of arrays, one of the arrays is a array of objects, which I tested separately and it's working fine, and another array of integer and another of strings. When I run the web service I got this:You must implement a default accessor on System.Array because it inherits from ICollectionDefault accessor what that means? Thank you very much.  As Heinlein said "specialization is for insects" explore beyond the universe. Could you pls post the relevant code ? hi rushan thank you for the reply the code is here:  ...

Array of Arrays
Hi, I am looking for a way to create an array of arrays which needs to be passed to Oracle database to minimize the round trips to hte server. I was successful in sending simple arrays so far but no idea on how to create array of arrays in PB. I have used structures to simulate this but looks like I can't send the structure to Oracle. Anyone has any suggestions? Thanks, Anil Please don't cross-post. On 3 Mar 2005 14:02:47 -0800, Anil wrote: >Hi, > >I am looking for a way to create an array of arrays which >needs to be passed to Oracle database t...

[@array] and \@array
Given the case, my @array = (1,2,3,4); my $var1 = [@array]; my $var2 = \@array; What's the difference between $var1 and $var2? Are they all refered to @array? Thanks guys. On 3/22/07, Jm lists <practicalperl@gmail.com> wrote: > Given the case, > > my @array = (1,2,3,4); > my $var1 = [@array]; > my $var2 = \@array; > > What's the difference between $var1 and $var2? > Are they all refered to @array? > Thanks guys. $var2 is a reference to @array. $var1 is a reference to new array. Observe #!/usr/bin/perl use strict; use war...

extracting elements from arrays of arrays of arrays ;-)
Hiya All, I hope you'll forgive this oo perl rookie for asking a routine question. I'm not new to perl, but the bioperl module I'm working on is giving me a headache! ;-) Let's say I have this: my @array = qw(12 56 41 23); my $array_ref = \@array; # where $var1, $var2, and $var3 are other array references. my $ref = [$var1, $var2, $array_ref, $var3 ]; my @object = (); push @object, $ref; QUESTION: How do I obtain the array $array_ref refers to in this situtation? Let's say I want to give @new the values in @array. Thank many thanks for you...

Confusion on @array vs $array[] vs $array
--=_FCA3CF00.8EEF86D1 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello: I have been fairly confused on the intermixing of array naming standards. If I understand correctly, the @array syntaxt is used to refer to the whole array, while $array[n] is refered to specific elements. In my thinking, it would have been less confusing to use @array[n] to address specific elements, but Perl complaines bitterly when warnings &/or strict is enabled. Is the rational for the "$"array[] character for identifying ...

grep array of arrays
Hello List, I'm trying to grep an array of arrays, but I am getting the following error: Can't use string ("1") as an ARRAY ref while "strict refs" in use at form.pl line 121, <$COORDS> line 1281. Press any key to continue . . . Below is the grep statement: print grep { $_->[0][0] >= 0 } @coords; Any idea what I am doing wrong? Thank in advance, Chris Chris Stinemetz wrote: > Hello List, Hello, > I'm trying to grep an array of arrays, but I am getting the following error: > > Can't use string ("1...

Web resources about - array of arrays - perl.beginners

Array - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Search with Relcy for an array of relevant, reliable results
... on the bandwagon? or Enjoy Apple TV 4 screensavers on Mac OS X with Aerial . Relcy - The Fastest Way to Find Search with Relcy for an array ...

GM to build solar array at transmission plant
Filed under: Green , Plants/Manufacturing , GM , Technology , Solar GM is partnering to build its largest solar array in Michigan near the Warren ...

New books for animal lovers deliver array of adventures, information
Who's on the bookshelves this month? Dogs, wolves, birds and cats. And butterflies. Beautiful butterflies. Here are some of the new animal-related ...

Rarely Seen ‘Ashes And Embers’ Getting Restoration & Distribution From Ava DuVernay‘s Array Releasing ...
Ava DuVernay 's Array Releasing has acquired director Haile Gerima ’s rarely-seen classic Ashes And Embers and will give it full restoration, ...

HPE 3PAR Celebrates Five Years, Refreshes Arrays, Software
Since HP wrestled 3PAR from Dell in a multibillion-dollar bidding war, the division has performed well for the corporation.

Sorting through wireless music’s dizzying array of options
The good news: Having clear-sounding audio all over your house no longer requires a second mortgage.

Sheldon Silver, Longtime Titan of New York Politics, Guilty On Array of Corruption Charges
Sheldon Silver, who has been speaker of the New York State Assembly for 20 years, was found guilty today in federal court of seven corruption ...

Alien megastructures? SETI Institute’s Allen Telescope Array targets weirdly winking star
One of the premier telescope arrays in the search for extraterrestrial intelligence, or SETI, is focusing its antennas on an anomalously blinking ...

El Cheapo Phased-Array Sonar
... — the range to the closest object that the speaker is pointing at. It doesn’t have to be that way. [Graham Chow] built a simple phased-array ...

Resources last updated: 12/23/2015 11:39:18 AM