mlebel has asked for the wisdom of the Perl Monks concerning the following question:
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...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: need helpt to fix "use of uninitialized value..."
by moritz (Cardinal) on Feb 16, 2012 at 13:45 UTC | |
|
Re: need helpt to fix "use of uninitialized value..."
by DStaal (Chaplain) on Feb 16, 2012 at 14:03 UTC | |
|
Re: need help to fix "use of uninitialized value..."
by mlebel (Hermit) on Feb 16, 2012 at 16:18 UTC | |
by Anonymous Monk on Feb 17, 2012 at 00:32 UTC | |
by mlebel (Hermit) on Feb 18, 2012 at 01:52 UTC | |
by Marshall (Canon) on Feb 17, 2012 at 05:36 UTC | |
by mlebel (Hermit) on Feb 18, 2012 at 02:15 UTC |