Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: The simplest possible pattern match defeats me

by logan (Curate)
on May 23, 2013 at 03:18 UTC ( #1034848=note: print w/ replies, xml ) Need Help??


in reply to Re: The simplest possible pattern match defeats me
in thread The simplest possible pattern match defeats me

Fair enough, it's a string compare rather than a pattern match. It's a simple eq, which should compare the string contained in $oldString to the value in quotes. Still, I get that uninitialized value error. The reason that there's a big gap between line 84 and line 103 is that I have a chunk commented out with an =item =cut block. Perhaps this will help. I've removed that block to make sure it wasn't causing the problem.

80 my $oldString = $allChanges->[$k]->getOldString(); 81 my $newString = $allChanges->[$k]->getNewString(); 82 $logger->debug("oldString = (", $oldString, ")"); 83 $logger->debug("newString = (", $newString, ")"); 84 print Dumper($oldString); 85 sleep 1; 86 87 if ($oldString eq "Automated") { 88 $logger->debug("old string = ", $oldString); 89 $logger->debug("new string = ", $newString); 90 }
Output:
INFO main:::78: Change 2 was to the Automated field of testCase HIREX- +16845 on createdDate 2013-05-13 11:34:52 Old String = (Ready For Inte +gration) New String = Automated DEBUG main:::82: oldString = (Ready For Integration) DEBUG main:::83: newString = (Automated) $VAR1 = 'Ready For Integration'; Use of uninitialized value in pattern match (m//) at weeklyAutomationC +hanges.pl line 87. Use of uninitialized value in pattern match (m//) at weeklyAutomationC +hanges.pl line 87. DEBUG main:::352: old string = Ready For Integration DEBUG main:::353: new string = Automated DEBUG main:::355: New string = Automated

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


Comment on Re^2: The simplest possible pattern match defeats me
Select or Download Code
Re^3: The simplest possible pattern match defeats me
by LanX (Canon) on May 23, 2013 at 03:23 UTC
    Again the error msgs don't fit!

    That's how it looks like if eq fails:

    DB<100> use warnings; $a eq "a" Use of uninitialized value $a in string eq at ...

    So where is the pattern match (m//) at weeklyAutomationChanges.pl line 87.?

    Are you debugging the right file?

    Which perl version do you use?

    Cheers Rolf

    ( addicted to the Perl Programming Language)

      1) Yes, the fact that the error is for a failed pattern match and not a failed 'eq' is doubly confusing. That's one reason I posted to Perlmonks. Check my profile, Rolf. I've been coding perl for 15 years. That's not a "Don't question me, I know what I'm doing" statement. It's an "I've been doing this for 1/3 of my life. Why is this simple thing suddenly so hard?" statement.

      2) I'm sure I'm debugging the right file because when I add or remove lines from the file the line numbers in the output change. Moreover, if I change the text around the offending code those changes are reflected in the output.

      3) I'm using perl v5.8.8 built for x86_64-linux-thread-multi.

      I added a couple of extra checks and the results do point me in a direction. When I assign a string value to $oldString and test it with an eq (lines 80 - 89), no problem. If I assign the value with a call to $oldString = $allChanges->[$k]->getOldString(); the problem manifests. That's even more curious, because the call to print Dumper($oldString); at line 95 prints a simple string.

      80 local $oldString = "OLDSTRING"; 81 local $newString = "NEWSTRING"; 82 $logger->debug("oldString = (", $oldString, ")"); 83 $logger->debug("newString = (", $newString, ")"); 84 if ($oldString eq "OLDSTRING") { 85 $logger->info("$oldString = $oldString"); 86 } 87 else { 88 $logger->info("No. $oldString != oldString"); 89 } 90 91 $oldString = $allChanges->[$k]->getOldString(); 92 $newString = $allChanges->[$k]->getNewString(); 93 $logger->debug("oldString = (", $oldString, ")"); 94 $logger->debug("newString = (", $newString, ")"); 95 print Dumper($oldString); 96 sleep 1; 97 98 if ($oldString eq "Automated") { 99 $logger->debug("old string = ", $oldString); 100 $logger->debug("new string = ", $newString);
      Results
      INFO main:::79: Change 3 was to the Automated field of testCase HIREX- +16863 on createdDate 2013-05-13 12:19:42 Old String = (To Be Automate +d) New String = Ready For Integration DEBUG main:::82: oldString = (OLDSTRING) DEBUG main:::83: newString = (NEWSTRING) INFO main:::84: OLDSTRING = OLDSTRING DEBUG main:::93: oldString = (To Be Automated) DEBUG main:::94: newString = (Ready For Integration) $VAR1 = 'To Be Automated'; Use of uninitialized value in pattern match (m//) at weeklyAutomationC +hanges.pl line 98. Use of uninitialized value in pattern match (m//) at weeklyAutomationC +hanges.pl line 98.

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

        Hi logan

        > Yes, the fact that the error is for a failed pattern match and not a failed eq is doubly confusing

        I don't think that 5.8.8 had different error msgs. (you could check)

        Anyway is it possible that someone overloaded eq with a routine doing a regex-match?

        Is the value in question maybe an object? What does ref return?

        Cheers Rolf

        ( addicted to the Perl Programming Language)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1034848]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (11)
As of 2014-09-30 19:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (381 votes), past polls