in reply to Re: need help to fix "use of uninitialized value..."
in thread need help to fix "use of uninitialized value..."

In Perl >5.10, there is a new operator //=. This checks for "definedness". $Pairs{$Person1}   //= $Person1; the hash value is assigned the value of $Person1 if that hash value wasn't already defined.

You cannot use an undefined value in a string concatenation. So, $PairsOf{$Person1} //= ""; will define $PairsOf{$Person1} to be a null string if it isn't already defined. If the value is already defined, then this should have no effect. A null string can be used in a concatenation.

$Pairs{$Person1} //= $Person1; $Pairs{$Person2} //= $Person2; $PairsOf{$Person1} //= ""; $PairsOf{$Person2} //= ""; $PairsOf{$Person1} = $PairsOf{$Person1} . " " . $Person2; $PairsOf{$Person2} = $PairsOf{$Person2} . " " . $Person1;

Replies are listed 'Best First'.
Re^3: need help to fix "use of uninitialized value..."
by mlebel (Hermit) on Feb 18, 2012 at 02:15 UTC

    Now this fixed my problem, thank you very much!, I now have more homework to do on learning the new features of perl :)

    thanks again!