http://qs321.pair.com?node_id=1034839

logan has asked for the wisdom of the Perl Monks concerning the following question:

I'm having a hard time with what seems like a really simple issue: comparing a string to a variable. I've pored over the Camel book and the docs for a disturbing amount of time and I'm stumped by something that hasn't been an issue for me for 15 years. For some reason when I run the code below I keep get warnings about uninitialized values in the pattern match.
while ($allChanges->[$k]) { $logger->info("Change $k was to the ", $allChanges->[$k]->getField( +), " field of testCase ", $allChanges->[$k]->getKey(), " on createdDa +te ", $allChanges->[$k]->printCreatedDate(), " Old String = (", $allC +hanges->[$k]->getOldString(), ") New String = ", $allChanges->[$k]->g +etNewString()); local $oldString = $allChanges->[$k]->getOldString(); local $newString = $allChanges->[$k]->getNewString(); $logger->debug("oldString = (", $oldString, ")"); $logger->debug("newString = (", $newString, ")"); print Dumper($oldString); if ($oldString eq "Automated") { # Line 103, the one that gives all + the trouble. $logger->debug("old string = Automated: ", $oldString); $logger->debug("new string: ", $newString); } } package ChangeItem; sub new { my $class = shift; my $logger = get_logger("ChangeItem"); my $self = { } ; if (@_) { $self->{line} = shift @_; } $self->{key} = 0; $self->{field} = 0; $self->{oldString} = 0; $self->{newString} = 0; $self->{createdDate} = 0; $self->{version} = 0; bless ($self, $class); return $self; } sub setOldString { my $self = shift; $self->{oldString} = shift; } sub getOldString { my $self = shift; return $self->{oldString}; }
When I run the code I keep getting warnings about uninitialized values in the pattern match
INFO main:::80: Change 0 was to the Automated field of testCase HIREX- +16861 on createdDate 2013-05-13 10:16:05 Old String = (To Be Automate +d) New String = Ready For Integration DEBUG main:::84: oldString = (To Be Automated) DEBUG main:::85: newString = (Ready For Integration) $VAR1 = 'To Be Automated'; Use of uninitialized value in pattern match (m//) at weeklyAutomationC +hanges.pl line 103. Use of uninitialized value in pattern match (m//) at weeklyAutomationC +hanges.pl line 103.
The value of $oldString is populated by a call to ChangeItem::getOldString(). I can see that it has a value because it's being printed. I've checked that the value is a simple scalar by sending it to Data::Dumper ($VAR1 = 'To Be Automated';). I feel like I'm missing something incredibly basic but at this point I'm baffled.

-Logan
"What do I want? I'm an American. I want more."