Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Can call array but not index of an array in subroutine?!

by fraizerangus (Sexton)
on Apr 02, 2009 at 19:33 UTC ( [id://755086]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Can call array but not index of an array in subroutine?!
in thread Can call array but not index of an array in subroutine?!

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^4: Can call array but not index of an array in subroutine?!
by jethro (Monsignor) on Apr 02, 2009 at 20:49 UTC

    Ok, I see you changed the lines inside the loop, to something that is definitely wrong as long as you don't change the rest. Please put it back as it were (i.e to @Axcord[$counter] =...). The code is not pretty, but it is not really wrong. Also add "\n" after your print statements so your debug output is not all on one line. You might also change one of the print lines this way to give more information:

    print STDOUT "should print out \@Axcord array but does'nt?! |", join(' +|',@Axcord),"|",scalar(@Axcord),\n";

    That will print '|' between anything that is in the array and also the size of the array. After that execute and tell us what gets printed and (if possible) what you would expect.

    Also you might put similar print statements at the beginning of the subroutine to find out what input values the subroutine gets. Maybe the routine does everything right and it is the input that is wrong.

    By the way, you forgot code tags around your data, this way it is unusable. But anyway it is a bit large, usually you should try to trim down the problem as much as you can, code as well as data.

      Hi everyone! I've just found out the problem seems to be that some of the arrays I am creating are infact negative arrays?! does anyone know why this might be happening or what I can do to reverse it?! best wishes Dan

        What do you consider a "negative array"? Is it:

        1. A data structure where the index is arbitrary but the values are always the range 0 to (number of items-1)?
        2. A data structure where the values are arbitrary but the index is always in the range 0 down to -(number of items-1)?
        3. A normal array?

        If you're wondering, you can access Perl arrays with positive and negative values for the index, where positive values count from the front and negative values count from the end of the array.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-25 05:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found