in reply to Re: pattern match showes true
in thread pattern match showes true

hi, I am still not able to match the values. I have a problem comparing values like
$preprod->{$siebdb} = $k; #$k is /siebprod/db13/PRODDB/log2/ $prod->{$siebdb} = $j; # $j is /preprod/db12/PREPRODDB/log2/
any idea how I should compare these?

Replies are listed 'Best First'.
Re^3: pattern match showes true
by FunkyMonk (Bishop) on Jul 31, 2007 at 19:25 UTC
    Run the following, and tell us what the output is:

    $preprod->{$siebdb} = $k; print "[$k]\n"; $prod->{$siebdb} = $j; print "[$j]\n"; if ( $preprod->{$siebdb} eq $prod->{$siebdb} ) { print "SAME\n" } else { print "DIFFERENT\n" }

Re^3: pattern match showes true
by ysth (Canon) on Jul 31, 2007 at 19:35 UTC
    Do what FunkyMonk said. Also, when you show us what you are doing, you're being just a little bit too terse; seeing larger parts of your actual code might help us help you better (not too large - remove as much as you can while still leaving enough to create the problem).

    I can think of three possible problems you might be having, other than simple syntax misuse: one of your strings might have a newline at the end, making them not exactly equal; $prod and $preprod could be referring to different hashes than you expect; $siebdb could be something different than you expect either when storing the values in the hash or when doing the comparison.

    We'd really have to see more of your code to tell what's up.

      hi again, I am building two saperate hashes as
      my($q1,$a1) = split(/=/); $prod->{$environment}{$dbname}{$q1} = $a1; my($rt,$ap) = split(/=/); $preprod->{$env}{$database}{$rt} = $ap; and then comparing the values as if ($preprod->{$env}{$database}{$rt} ne $prod->{$environment}{$dbname} +{$q1) { print "$preprod->{$env}{$database}{$rt}\n" }
      I get all the values correct except
      #$a1 is /siebprod/db13/PRODDB/log2/ #$ap is /preprod/db12/PREPRODDB/log2/
        In place of your if, try putting
        use Data::Dumper; $Data::Dumper::Useqq = 1; $Data::Dumper::Terse = 1; print "preprod is at $preprod, env is ", Dumper($env), " database is " +, Dumper($database), " rt is ", Dumper($rt), " value is ", Dumper($pr +eprod->{$env}{$database}{$rt}), "\n"; print "prod is at $prod, environment is ", Dumper($environment), " dbn +ame is ", Dumper($dbname), " q1 is ", Dumper($q1), " value is ", Dump +er($prod->{$environment}{$dbname}{$q1}), "\n";
        and see if anything looks different than you expect.