Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
laziness, impatience, and hubris
 
PerlMonks  

Re^4: random pairs

by Anonymous Monk
on Jul 19, 2012 at 16:43 UTC ( #982661=note: print w/ replies, xml ) Need Help??


in reply to Re^3: random pairs
in thread random pairs

I keep getting errors about $element and $pairs being uninitialized. I was wondering what you had set for the value of those two elements for your loop. I want to store $pairs into an array by the value of $element but I can't.


Comment on Re^4: random pairs
Re^5: random pairs
by CountZero (Chancellor) on Jul 19, 2012 at 19:41 UTC
    Difficult to say why you get these warnings.

    By now I have lost track of how your program looks and I cannot reproduce these warnings in my script.

    I guess the problem is with this code:

    push @results, $element.'-'.$pair; foreach (@results) { ($element.','.$pair) = split; $element{$_} = $element; } }
    You are splitting the elements of @results on whitespace and there is no whitespace in these elements, so split is not doing what you think it does.

    Also, ($element.','.$pair) looks really strange. What are you trying to do with it? I have never seen his on the left side of an assignment.

    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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2013-06-18 04:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How many continents have you visited?









    Results (595 votes), past polls