A Question

D

david

hi:

The code below:

my $array = $Sheet->Range("A1:AH232")->{Value};

foreach my $ref_array (@$array) { # loop through
the array
# referenced by
$array
foreach my $scalar (@$ref_array) {
if (defined($scalar)) {
print TESTFILE "$scalar\t";
}
}
print TESTFILE "\n";

}

What's the meaning of (@$array) and (@$ref_array)?
I am confused here.
 
P

Paul Lalli

david said:
Subject:: A Question

Please put the subject of your post in the Subject of your post. Your
post was not about questions. Your question was about the @$foo
notation.
my $array = $Sheet->Range("A1:AH232")->{Value};

foreach my $ref_array (@$array) { # loop through the array
# referenced by $array
foreach my $scalar (@$ref_array) {
if (defined($scalar)) {
print TESTFILE "$scalar\t";
}
}
print TESTFILE "\n";

}

What's the meaning of (@$array) and (@$ref_array)?

Exactly what that comment said it is. You're looping through the array
that's referenced by the variable $array.

$array is a reference to an array. @$array is how you dereference a
reference, to get at the actual array that $array references.
I am confused here.

Read up on references and multi-dimensional structures

perldoc perlreftut
perldoc perllol
perldoc perldsc
perldoc perlref

I also strongly recommend the book "Learning Perl Objects, References,
and Modules" (which will soon (or possibly already?) be renamed
"Intermediate Perl") by Randal Schwartz, Tom Phoenix, and bryan d foy.
It picks up right where the standard "Learning Perl" book leaves off.

Paul Lalli
 
D

david

How can I get the element in the array (@$array)? For instance, I want
to get the number 2 of the array. I can use $(@$array)[2]?

thx
 
A

A. Sinan Unur

How can I get the element in the array (@$array)? For instance, I want
to get the number 2 of the array. I can use $(@$array)[2]?

What happened when you tried?

Sinan
 
J

Jürgen Exner

david said:
How can I get the element in the array (@$array)? For instance, I
want to get the number 2 of the array. I can use $(@$array)[2]?

No, that would return the third element of the array.
Besides, you probably meant to use curly braces instead of paranthesis.

BTW: I suggest to read
perldoc perlreftut (in particular the first rule)
perldoc perlref

jue
 
K

Keith Keller

How can I get the element in the array (@$array)? For instance, I want
to get the number 2 of the array. I can use $(@$array)[2]?

Did you read the documentation that Paul and Sinan referenced?

Have you read the posting guidelines? If not, please do; if so, please
follow them in the future.

--keith
 
P

Paul Lalli

david said:
How can I get the element in the array (@$array)? For instance, I want
to get the number 2 of the array. I can use $(@$array)[2]?

.... At least two people, myself included, already told you the
documentation to read to learn how to use array references.

Either you haven't done so, or you didn't understand it.

If you haven't done so, you are showing a lack of desire to learn, in
preference to just having people answer your questions with no effort
of your own.

If you have read it, and you don't understand, point out what parts of
the documenation are confusing you.

Paul Lalli
 
D

david

Lots of output:

----------------- 0ARRAY(0x21dbeac) ARRAY(0x21966b8) ARRAY(0x21ecce8)
ARRAY(0x21
ece98) ARRAY(0x21ed048) ARRAY(0x21ed1f8) ARRAY(0x21ed3a8)
ARRAY(0x21ed558) ARRAY
(0x21ed708) ARRAY(0x21ed8b8) ARRAY(0x21eda68) ARRAY(0x21edc18)
ARRAY(0x21f003c)
ARRAY(0x21f01ec) ARRAY(0x21f039c) ARRAY(0x21f054c) ARRAY(0x21f06fc)
ARRAY(0x21f0
8ac) ARRAY(0x21f0a5c) ARRAY(0x21f0c0c) ARRAY(0x21f0dbc)
ARRAY(0x21f4ae0) ARRAY(0
x21f4c90) ARRAY(0x21f4e40) ARRAY(0x21f4ff0) ARRAY(0x21f51a0)
ARRAY(0x21f5350) AR
RAY(0x21f5500) ARRAY(0x21f56b0) ARRAY(0x21f5860) ARRAY(0x21f5a10)
ARRAY(0x21f7c6
c) ARRAY(0x21f7e1c) ARRAY(0x21f7fcc) ARRAY(0x21f817c) ARRAY(0x21f832c)
ARRAY(0x2
1f84dc) ARRAY(0x21f868c) ARRAY(0x21f883c) ARRAY(0x21f89ec)
ARRAY(0x21fb6f0) ARRA
Y(0x21fb8a0) ARRAY(0x21fba50) ARRAY(0x21fbc00) ARRAY(0x21fbdb0)
ARRAY(0x21fbf60)
ARRAY(0x21fc110) ARRAY(0x21fc2c0) ARRAY(0x21fc470) ARRAY(0x21ff9bc)
ARRAY(0x21f
fb6c) ARRAY(0x21ffd1c) ARRAY(0x21ffecc) ARRAY(0x220007c)
ARRAY(0x220022c) ARRAY(
0x22003dc) ARRAY(0x220058c) ARRAY(0x220073c) ARRAY(0x22008ec)
ARRAY(0x2203008) A
RRAY(0x22031b8) ARRAY(0x2203368) ARRAY(0x2203518) ARRAY(0x22036c8)
ARRAY(0x22038
78) ARRAY(0x2203a28) ARRAY(0x2203bd8) ARRAY(0x2203d88) ARRAY(0x2208004)
ARRAY(0x
22081b4) ARRAY(0x2208364) ARRAY(0x2208514) ARRAY(0x22086c4)
ARRAY(0x2208874) ARR
AY(0x2208a24) ARRAY(0x2208bd4) ARRAY(0x2208d84) ARRAY(0x2208f34)
ARRAY(0x220aef0
) ARRAY(0x220b0a0) ARRAY(0x220b250) ARRAY(0x220b400) ARRAY(0x220b5b0)
ARRAY(0x22
0b760) ARRAY(0x220b910) ARRAY(0x220bac0) ARRAY(0x220bc70)
ARRAY(0x220f60c) ARRAY
(0x220f7bc) ARRAY(0x220f96c) ARRAY(0x220fb1c) ARRAY(0x220fccc)
ARRAY(0x220fe7c)
ARRAY(0x221002c) ARRAY(0x22101dc) ARRAY(0x221038c) ARRAY(0x2213b70)
ARRAY(0x2213
d20) ARRAY(0x2213ed0) ARRAY(0x2214080) ARRAY(0x2214230)
ARRAY(0x22143e0) ARRAY(0
x2214590) ARRAY(0x2214740) ARRAY(0x22148f0) ARRAY(0x2214aa0)
ARRAY(0x22164f4) AR
RAY(0x22166a4) ARRAY(0x2216854) ARRAY(0x2216a04) ARRAY(0x2216bb4)
ARRAY(0x2216d6
4) ARRAY(0x2216f14) ARRAY(0x22170c4) ARRAY(0x2217274) ARRAY(0x2218f20)
ARRAY(0x2
2190d0) ARRAY(0x2219280) ARRAY(0x2219430) ARRAY(0x22195e0)
ARRAY(0x2219790) ARRA
Y(0x2219940) ARRAY(0x2219af0) ARRAY(0x2219ca0) ARRAY(0x2219e50)
ARRAY(0x221be84)
ARRAY(0x221c034) ARRAY(0x221c1e4) ARRAY(0x221c394) ARRAY(0x221c544)
ARRAY(0x221
c6f4) ARRAY(0x221c8a4) ARRAY(0x221ca54) ARRAY(0x221cc04)
ARRAY(0x22048d8) ARRAY(
0x221f9d0) ARRAY(0x221fb80) ARRAY(0x221fd30) ARRAY(0x221fee0)
ARRAY(0x2220090) A
RRAY(0x2220240) ARRAY(0x22203f0) ARRAY(0x22205a0) ARRAY(0x2220750)
ARRAY(0x22209
00) ARRAY(0x2221f0c) ARRAY(0x22220bc) ARRAY(0x222226c) ARRAY(0x222241c)
ARRAY(0x
22225cc) ARRAY(0x222277c) ARRAY(0x222292c) ARRAY(0x2222adc)
ARRAY(0x2222c8c) ARR
AY(0x2225178) ARRAY(0x2225328) ARRAY(0x22254d8) ARRAY(0x2225688)
ARRAY(0x2225838
) ARRAY(0x22259e8) ARRAY(0x2225b98) ARRAY(0x2225d48) ARRAY(0x2225ef8)
ARRAY(0x22
260a8) ARRAY(0x222769c) ARRAY(0x222784c) ARRAY(0x22279fc)
ARRAY(0x2227bac) ARRAY
(0x2227d5c) ARRAY(0x2227f0c) ARRAY(0x22280bc) ARRAY(0x222826c)
ARRAY(0x222841c)
ARRAY(0x222a998) ARRAY(0x222ab48) ARRAY(0x222acf8) ARRAY(0x222aea8)
ARRAY(0x222b
058) ARRAY(0x222b208) ARRAY(0x222b3b8) ARRAY(0x222b568)
ARRAY(0x222b718) ARRAY(0
x222ccec) ARRAY(0x222ce9c) ARRAY(0x222d04c) ARRAY(0x222d1fc)
ARRAY(0x222d3ac) AR
RAY(0x222d55c) ARRAY(0x222d70c) ARRAY(0x222d8bc) ARRAY(0x222da6c)
ARRAY(0x222dc1
c) ARRAY(0x2230108) ARRAY(0x22302b8) ARRAY(0x2230468) ARRAY(0x2230618)
ARRAY(0x2
2307c8) ARRAY(0x2230978) ARRAY(0x2230b28) ARRAY(0x2230cd8)
ARRAY(0x2230e88) ARRA
Y(0x2232a1c) ARRAY(0x2232bcc) ARRAY(0x2232d7c) ARRAY(0x2232f2c)
ARRAY(0x22330dc)
ARRAY(0x223328c) ARRAY(0x223343c) ARRAY(0x22335ec) ARRAY(0x223379c)
ARRAY(0x223
394c) ARRAY(0x2236940) ARRAY(0x2236af0) ARRAY(0x2236ca0)
ARRAY(0x2236e50) ARRAY(
0x2237000) ARRAY(0x22371b0) ARRAY(0x2237360) ARRAY(0x2237510)
ARRAY(0x22376c0) A
RRAY(0x223b1b4) ARRAY(0x223b364) ARRAY(0x223b514) ARRAY(0x223b6c4)
ARRAY(0x223b8
74) ARRAY(0x223ba24) ARRAY(0x223bbd4) ARRAY(0x223bd84) ARRAY(0x223bf34)
ARRAY(0x
223e308) ARRAY(0x223e4b8) ARRAY(0x223e668)){1}
----------------- 0ARRAY(0x21dbeac) ARRAY(0x21966b8) ARRAY(0x21ecce8)
ARRAY(0x21
ece98) ARRAY(0x21ed048) ARRAY(0x21ed1f8) ARRAY(0x21ed3a8)
ARRAY(0x21ed558) ARRAY
(0x21ed708) ARRAY(0x21ed8b8) ARRAY(0x21eda68) ARRAY(0x21edc18)
ARRAY(0x21f003c)
ARRAY(0x21f01ec) ARRAY(0x21f039c) ARRAY(0x21f054c) ARRAY(0x21f06fc)
ARRAY(0x21f0
8ac) ARRAY(0x21f0a5c) ARRAY(0x21f0c0c) ARRAY(0x21f0dbc)
ARRAY(0x21f4ae0) ARRAY(0
x21f4c90) ARRAY(0x21f4e40) ARRAY(0x21f4ff0) ARRAY(0x21f51a0)
ARRAY(0x21f5350) AR
RAY(0x21f5500) ARRAY(0x21f56b0) ARRAY(0x21f5860) ARRAY(0x21f5a10)
ARRAY(0x21f7c6
c) ARRAY(0x21f7e1c) ARRAY(0x21f7fcc) ARRAY(0x21f817c) ARRAY(0x21f832c)
ARRAY(0x2
1f84dc) ARRAY(0x21f868c) ARRAY(0x21f883c) ARRAY(0x21f89ec)
ARRAY(0x21fb6f0) ARRA
Y(0x21fb8a0) ARRAY(0x21fba50) ARRAY(0x21fbc00) ARRAY(0x21fbdb0)
ARRAY(0x21fbf60)
ARRAY(0x21fc110) ARRAY(0x21fc2c0) ARRAY(0x21fc470) ARRAY(0x21ff9bc)
ARRAY(0x21f
fb6c) ARRAY(0x21ffd1c) ARRAY(0x21ffecc) ARRAY(0x220007c)
ARRAY(0x220022c) ARRAY(
0x22003dc) ARRAY(0x220058c) ARRAY(0x220073c) ARRAY(0x22008ec)
ARRAY(0x2203008) A
RRAY(0x22031b8) ARRAY(0x2203368) ARRAY(0x2203518) ARRAY(0x22036c8)
ARRAY(0x22038
78) ARRAY(0x2203a28) ARRAY(0x2203bd8) ARRAY(0x2203d88) ARRAY(0x2208004)
ARRAY(0x
22081b4) ARRAY(0x2208364) ARRAY(0x2208514) ARRAY(0x22086c4)
ARRAY(0x2208874) ARR
AY(0x2208a24) ARRAY(0x2208bd4) ARRAY(0x2208d84) ARRAY(0x2208f34)
ARRAY(0x220aef0
) ARRAY(0x220b0a0) ARRAY(0x220b250) ARRAY(0x220b400) ARRAY(0x220b5b0)
ARRAY(0x22......
 
K

Keith Keller

[context snipped, yet again, contrary to posting guidelines]
Yes, No time to read the document yet. I hope I can solve it.

As I told another poster who would not read and follow the posting
guidelines, if you want free help, you should probably exercise some
common courtesy when posting. This includes reading the documentation
that people suggest before posting back. If you don't do so, you risk
alienating the people you're asking for help.

--keith
 
S

Scott Bryce

david said:
Yes, No time to read the document yet. I hope I can solve it.

You will solve it faster if you read the documentation first. Or did you
expect the regulars here to solve it for you? You don't have the time,
but we do?

BTW, please quote enough of the post you are replying to to give us some
idea what and who you are responding to.
 
R

Reginald Murphy

Keith Keller said:
On 2006-03-14, david <[email protected]> wrote:

Keith Keller is a well known troll from alt.os.linux.slackware. In
that group he champions the use of PGP in message signatures in
order to curry favour with a few of the posters who do that. But
because he wishes to curry favour in this newsgroup, he has buried
his PGP garbage in his headers.

Keith Keller is a cowardly, small, hypocritical piece of shit. He
curries favour and this is how he gets by in life.

Do yourselves all a big favour and put this little hamster into your
killfiles where he belongs. Please do not respond to his postings.

cordially, as always,

rm
 
T

Tad McClellan

david said:


Yes to what question?

Please quote some context in followups like everybody else does.

No time to read the document yet.


It would take you less time to read the 7 pages of perlreftut.pod
than you spent typing up these Usenet postings.

I hope I can solve it.


Spend 15 minutes with perlreftut.pod and it will be solved!
 
J

Jürgen Exner

david said:

Yes _WHAT_?
When replying please quote an appropriate amount of context -as has been a
proven custom for the last 2 decades- such that people have a chance to know
what you are talking about.
No time to read the document yet.

That is not an excuse for poor mannners.
I hope I can solve it.

You surely can. The solution is probably right there in front of you,
sitting in the docs and waiting to be discovered.

jue
 
J

Jürgen Exner

david said:
Lots of output:

----------------- 0ARRAY(0x21dbeac) ARRAY(0x21966b8) ARRAY(0x21ecce8)
ARRAY(0x21
ece98) ARRAY(0x21ed048) ARRAY(0x21ed1f8) ARRAY(0x21ed3a8)
ARRAY(0x21ed558) ARRAY
[...]

Well, that's just great. And what are we supposed to do with that dump?

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top