$str1 eq $str2 causing problems

Discussion in 'Perl Misc' started by Ashish Gupta, Aug 22, 2005.

  1. Ashish  Gupta

    Ashish Gupta Guest

    need some help in perl please.

    i am comparing two strings both of which are supposed to be equal, but
    the if condition returns false.

    i am pasting the debugger portion below:


    DB<2> v
    1052: $server_name =~ s/\s*//g;
    1053: $p_server =~ s/\s*//g;
    1054
    1055==> if ($server_name eq $p_server){
    1056: for ($i=0; $i < scalar(@login_password);
    $i+=2){
    1057: $login = $login_password[$i];
    1058: $password =
    $login_password[$i+1];
    1059: $login =~ s/\s*//g;
    1060: if ($login eq $p_user){
    1061: chomp($password);
    DB<2> x $server_name
    0 'SYB_DBA61_TKD'
    DB<3> x $p_server
    0 'SYB_DBA61_TKD'
    DB<4> s
    dba_syb_lib::sfi_connection_info(dba_syb_lib.pm:1066):
    1066: }
    DB<4>


    note that even though $server_name and $p_server seem to be equal,
    the if condition returns false and we jump to the closing brace on line
    1066.

    thanks,
    ashish
     
    Ashish Gupta, Aug 22, 2005
    #1
    1. Advertising

  2. Ashish  Gupta

    Ashish Gupta Guest

    Hi,

    I was able to figure out the problem.

    Actually, the debugger is not jumping to the closing } of the if stmt.

    For some strange reason, it starts off a for loop with its closing } !

    The } on line 1066 is for the for loop enclosed within the if.

    The program was failing overall because of another bug within the for
    loop. And my attention shifted to the if stmt because of the quirky way
    the debugger starts a for loop.

    Thanks,
    Ashish



    Ashish Gupta wrote:
    > need some help in perl please.
    >
    > i am comparing two strings both of which are supposed to be equal, but
    > the if condition returns false.
    >
    > i am pasting the debugger portion below:
    >
    >
    > DB<2> v
    > 1052: $server_name =~ s/\s*//g;
    > 1053: $p_server =~ s/\s*//g;
    > 1054
    > 1055==> if ($server_name eq $p_server){
    > 1056: for ($i=0; $i < scalar(@login_password);
    > $i+=2){
    > 1057: $login = $login_password[$i];
    > 1058: $password =
    > $login_password[$i+1];
    > 1059: $login =~ s/\s*//g;
    > 1060: if ($login eq $p_user){
    > 1061: chomp($password);
    > DB<2> x $server_name
    > 0 'SYB_DBA61_TKD'
    > DB<3> x $p_server
    > 0 'SYB_DBA61_TKD'
    > DB<4> s
    > dba_syb_lib::sfi_connection_info(dba_syb_lib.pm:1066):
    > 1066: }
    > DB<4>
    >
    >
    > note that even though $server_name and $p_server seem to be equal,
    > the if condition returns false and we jump to the closing brace on line
    > 1066.
    >
    > thanks,
    > ashish
     
    Ashish Gupta, Aug 22, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lars Langer

    strstr(char *str1, char *str2)

    Lars Langer, Sep 24, 2004, in forum: C Programming
    Replies:
    12
    Views:
    732
    Dan Pop
    Sep 28, 2004
  2. KL

    str.find(str1) usage ?

    KL, Mar 4, 2006, in forum: C++
    Replies:
    4
    Views:
    340
  3. Shea Martin

    "str1" == "STR1" case insensitive

    Shea Martin, Mar 21, 2006, in forum: Ruby
    Replies:
    2
    Views:
    94
  4. Joe Ruby MUDCRAP-CE

    str1 = str2 is not a copy?!?

    Joe Ruby MUDCRAP-CE, Nov 2, 2006, in forum: Ruby
    Replies:
    9
    Views:
    100
    Gregory Brown
    Nov 4, 2006
  5. wx
    Replies:
    1
    Views:
    90
    yermej
    Dec 8, 2007
Loading...

Share This Page