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

Hi monks, quick question, I have two variables, $dpage and $REPOSIT. Both have the value: /****/****/*********/public_html/weapons However,the following: if ($dpage eq $REPOSIT) never gets evaluated to true. Does Perl have a problem comparing strings with slashes? Thanks.

Replies are listed 'Best First'.
Re: Comparing directories
by NetWallah (Canon) on Mar 10, 2004 at 21:41 UTC
    There may be subtle/invisible differences in the contents of the variables. Try
    use Data::Dumper;
    and
    print Dumper $dpage , $REPOSIT ,$dpage eq $REPOSIT

    and look at the contents.

Re: Comparing directories
by Happy-the-monk (Canon) on Mar 10, 2004 at 21:40 UTC

    no, Perl comes with no such troubles. But see yourself. Type-or-copy

    perl -we '$dpage = "/****/****/*********/public_html/weapons"; $REPOSIT = "/****/****/*********/public_html/weapons"; print "Hooray\n" if ( $dpage eq $REPOSIT )' # on a unix shell

    or in a Windows/DOS-box:

    perl -we "$dpage = '/****/****/*********/public_html/weapons'; $REPOSIT = '/****/****/*********/public_html/weapons'; print qq/Hooray\n/ if ( $dpage eq $REPOSIT )"

    Considering your problem: the values actually differ.

    Sören

      Do they differ? It prints 'Hooray' for me.

      Personally, I would suspect the comparison never gets executed, that some outer condition ensures that code is not invoked.

      I would urge using Data::Dumper, non-interactively, and of the debugger flag, -d ( or better yet, emacs and M-x perldbg ).

      --
      TTTATCGGTCGTTATATAGATGTTTGCA