Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: An Array without an Index

by Athanasius (Archbishop)
on Aug 13, 2012 at 09:01 UTC ( [id://987076]=note: print w/replies, xml ) Need Help??


in reply to An Array Without and Index

Hello Toppo, and welcome to the Monastery!

Two quick observations:

  1. @row=(); while (my @row = $stm->fetchrow_array){

    The my in the while loop creates a new @row variable each time through the loop. This is almost certainly not what you wanted. Update: You don’t want both! See the comment by Anonymous Monk, below.

  2. the array @results don't appear to have an index

    I don’t know what you’re trying to say here, but be assured that every element in every array has an index! See e.g. perldata.

I think more information is required before the monks can help you. Please provide a minimal but complete, working script that demonstrates the problem, along with sample input, and a description of the desired output.

HTH,

Athanasius <°(((><contra mundum

Replies are listed 'Best First'.
Re^2: An Array without an Index
by Anonymous Monk on Aug 13, 2012 at 09:10 UTC

    The my in the while loop creates a new @row variable each time through the loop. This is almost certainly not what you wanted.

    Actually it most certainly is -- the @row=(); is what is an error -- probably because OP isn't using strict and warnings

      He said the program runs under strict and warnings.

      But the @row = () and the my @row in the while loop are two distinct variables. Since he is not using the first @row, it does not seem to be the cause of his problems.

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      My blog: Imperial Deltronics

        He said the program runs under strict and warnings ... it does not seem to be the cause of his problems.

        Of course, this is just a symptom ( not coping with scoping ) ; the cause is indeterminable.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://987076]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-04-25 02:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found