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.

Replies are listed 'Best First'.
Re^5: random pairs
by CountZero (Bishop) 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