Hello everyone,
I had a friend help me make the following code a while back and unfortunately this friend has passed away.
The original script where this code belongs inside works, but it is having unexpected behaviors. So after turning on warnings, I discovered that I am getting the following error 5 times when I run the script:
"Use of uninitialized value within %PairsOf in concatenation (.) or string at ./test_removing_pair_unitialized_value_error.pl line 22, <DATA> line 14."I don't know if it's the cause of the unexpected behavior in my script but I would certainly like to have this fixed.
Here is a part of my script at it's simplest form..:
#!/usr/bin/perl use strict; use warnings; my @PairLines; my %Pairs; my %PairsOf; @PairLines = <DATA>; chomp(@PairLines); foreach my $Line (@PairLines) { chomp $Line; $Line =~ s/^\s*//; $Line =~ s/\s*$//; if ($Line =~ m/^Pairing Start (.*)\s+(.*).*/) { my $Person1 = $1; my $Person2 = $2; $Pairs{$Person1} = $Person1 if (!defined($Pairs{$Person1})); $Pairs{$Person2} = $Person2 if (!defined($Pairs{$Person2})); $PairsOf{$Person1} = $PairsOf{$Person1} . " " . $Person2; $PairsOf{$Person2} = $PairsOf{$Person2} . " " . $Person1; } } __DATA__ Pairing Start Person1 Person2 Pairing End ########################################### Pairing Start Person1 Person3 Pairing End ########################################### Pairing Start Person1 Person4 Pairing End ########################################### Pairing Start Person1 Person5 Pairing End ########################################### Pairing Start Person2 Person3 Pairing End
Would anyone know a quick fix to this without re-writing the whole thing?
Thanks...
In reply to need help to fix "use of uninitialized value..." by mlebel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |