Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Get same position value in 2nd array

by Phinix (Acolyte)
on Dec 21, 2012 at 03:30 UTC ( #1009845=note: print w/ replies, xml ) Need Help??


in reply to Get same position value in 2nd array

I have decided to attempt this with hashes, however am now confused as to why my loop doesn't evaluate the table in order. For example, this code:

use strict; my %table = qw/test0 0 test1 1 test2 2 test3 3 test4 4 test5 5 test6 6 + test7 7/; while ( my($key, $value) = each(%table) ) { if ($value ne '0') { print "$key = $value\n" } }

...produces the following result:

test5 = 5

test7 = 7

test1 = 1

test4 = 4

test6 = 6

test3 = 3

test2 = 2


Comment on Re: Get same position value in 2nd array
Download Code
Replies are listed 'Best First'.
Re^2: Get same position value in 2nd array
by BrowserUk (Pope) on Dec 22, 2012 at 01:30 UTC
    I have decided to attempt this with hashes

    You know you want ordered results, but decide to use an inherently unordered data structure; that's like wanting to travel to Vegas and buying a boat.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    RIP Neil Armstrong

Re^2: Get same position value in 2nd array
by Anonymous Monk on Dec 21, 2012 at 04:05 UTC
    Sure its evaluated in order :) it is not the order you want, but thats just how hashes work

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2015-08-29 06:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (343 votes), past polls