eq and =? problem?

Discussion in 'Perl Misc' started by Geoff Cox, Mar 20, 2007.

  1. Geoff Cox

    Geoff Cox Guest

    Hello,

    It would seem that the following code does not distinguish between the
    "bp" and the "bplanning". I thought that using eq and not =~ would
    work.

    Any ideas please?

    Cheers

    Geoff

    elsif ( $path eq
    "docs/applied-business/as/classroom-notes/edexcel/unit2/bp" ) {
    intro($path);
    appliedbusinessclassroomnotesedexcelunit2bp($path);
    }

    elsif ( $path eq
    "docs/applied-business/as/classroom-notes/edexcel/unit2/bplanning" ) {
    intro($path);
    appliedbusinessclassroomnotesedexcelunit2bplanning($path);
    }
     
    Geoff Cox, Mar 20, 2007
    #1
    1. Advertising


  2. > Any ideas please?


    This works just fine for me.

    How about providing the full script or a simple testcase?
     
    Adrian Ulrich, Mar 20, 2007
    #2
    1. Advertising

  3. Geoff Cox

    Geoff Cox Guest

    On Tue, 20 Mar 2007 10:41:29 +0100, Adrian Ulrich
    <> wrote:

    >
    >> Any ideas please?

    >
    >This works just fine for me.
    >
    >How about providing the full script or a simple testcase?


    Adrian,

    Thanks for your reply . odd!

    I will try again myself. As it stands I am taking info from a MySQL
    data base, a collection of php files and html files so not easy to
    come up with a simple test case but will give this a try.

    I found a solution by changing the bp to bisplans to avoid any
    confusion between bp and bplann.

    How did you test out the code I posted?!

    Cheers

    Geoff
     
    Geoff Cox, Mar 20, 2007
    #3
  4. [ comp.lang.perl is no longer a newsgroup. Please do not attempt
    to post there.
    ]


    Geoff Cox <Geoff> wrote:
    > Hello,
    >
    > It would seem that the following code does not distinguish between the
    > "bp" and the "bplanning". I thought that using eq and not =~ would
    > work.
    >
    > Any ideas please?



    One idea would be to give us a short and complete program that we
    can run that illustrats the problem you are having.

    Have you seen the Posting Guidelines that are posted here frequently?


    > elsif ( $path eq
    > "docs/applied-business/as/classroom-notes/edexcel/unit2/bp" ) {
    > intro($path);
    > appliedbusinessclassroomnotesedexcelunit2bp($path);
    > }
    >
    > elsif ( $path eq
    > "docs/applied-business/as/classroom-notes/edexcel/unit2/bplanning" ) {
    > intro($path);
    > appliedbusinessclassroomnotesedexcelunit2bplanning($path);
    > }


    -----------------------------------------------
    #!/usr/bin/perl
    use warnings;
    use strict;

    my $path = 'docs/applied-business/as/classroom-notes/edexcel/unit2/bp';

    if ( $path eq "docs/applied-business/as/classroom-notes/edexcel/unit2/bp")
    { print "bp\n" }
    else
    { print "NO bp\n" }


    $path = 'docs/applied-business/as/classroom-notes/edexcel/unit2/bplanning';

    if ( $path eq "docs/applied-business/as/classroom-notes/edexcel/unit2/bplanning")
    { print "bplanning\n" }
    else
    { print "NO bplanning\n" }
    -----------------------------------------------


    Works fine for me...


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Mar 20, 2007
    #4
  5. Geoff Cox

    Geoff Cox Guest

    On Tue, 20 Mar 2007 05:55:00 -0500, Tad McClellan
    <> wrote:

    >
    >[ comp.lang.perl is no longer a newsgroup. Please do not attempt
    > to post there.
    >]
    >
    >
    >Geoff Cox <Geoff> wrote:
    >> Hello,
    >>
    >> It would seem that the following code does not distinguish between the
    >> "bp" and the "bplanning". I thought that using eq and not =~ would
    >> work.
    >>
    >> Any ideas please?

    >
    >
    >One idea would be to give us a short and complete program that we
    >can run that illustrats the problem you are having.
    >
    >Have you seen the Posting Guidelines that are posted here frequently?
    >
    >
    >> elsif ( $path eq
    >> "docs/applied-business/as/classroom-notes/edexcel/unit2/bp" ) {
    >> intro($path);
    >> appliedbusinessclassroomnotesedexcelunit2bp($path);
    >> }
    >>
    >> elsif ( $path eq
    >> "docs/applied-business/as/classroom-notes/edexcel/unit2/bplanning" ) {
    >> intro($path);
    >> appliedbusinessclassroomnotesedexcelunit2bplanning($path);
    >> }

    >
    >-----------------------------------------------
    >#!/usr/bin/perl
    >use warnings;
    >use strict;
    >
    >my $path = 'docs/applied-business/as/classroom-notes/edexcel/unit2/bp';
    >
    >if ( $path eq "docs/applied-business/as/classroom-notes/edexcel/unit2/bp")
    > { print "bp\n" }
    >else
    > { print "NO bp\n" }
    >
    >
    >$path = 'docs/applied-business/as/classroom-notes/edexcel/unit2/bplanning';
    >
    >if ( $path eq "docs/applied-business/as/classroom-notes/edexcel/unit2/bplanning")
    > { print "bplanning\n" }
    >else
    > { print "NO bplanning\n" }
    >-----------------------------------------------
    >
    >
    >Works fine for me...



    Thanks Tad - a helpful comment.

    Cheers

    Geoff
     
    Geoff Cox, Mar 20, 2007
    #5
  6. > I found a solution by changing the bp to bisplans to avoid any
    > confusion between bp and bplann.


    Maybe something adds some weird/unwanded chars to $path

    print unpack("H*", $path)."\n";

    should display them.


    > How did you test out the code I posted?!


    #!/usr/bin/perl
    use strict;
    my $path = "docs/applied-business/as/classroom-notes/edexcel/unit2/bplanning";
    if ( $path eq "docs/applied-business/as/classroom-notes/edexcel/unit2/bp" ) {
    die "1\n";
    }
    elsif ( $path eq "docs/applied-business/as/classroom-notes/edexcel/unit2/bplanning" ) {
    die "2\n";
    }
    else {
    die "3\n";
    }
     
    Adrian Ulrich, Mar 20, 2007
    #6
  7. Geoff Cox

    Geoff Cox Guest

    On Tue, 20 Mar 2007 21:54:51 +0100, Adrian Ulrich
    <> wrote:

    >> I found a solution by changing the bp to bisplans to avoid any
    >> confusion between bp and bplann.

    >
    >Maybe something adds some weird/unwanded chars to $path
    >
    >print unpack("H*", $path)."\n";
    >
    >should display them.
    >
    >
    >> How did you test out the code I posted?!

    >
    >#!/usr/bin/perl
    >use strict;
    >my $path = "docs/applied-business/as/classroom-notes/edexcel/unit2/bplanning";
    >if ( $path eq "docs/applied-business/as/classroom-notes/edexcel/unit2/bp" ) {
    > die "1\n";
    >}
    >elsif ( $path eq "docs/applied-business/as/classroom-notes/edexcel/unit2/bplanning" ) {
    > die "2\n";
    >}
    >else {
    > die "3\n";
    >}



    Thanks Adrian - will give that a go.

    Cheers

    Geoff
     
    Geoff Cox, Mar 20, 2007
    #7
    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. Eric
    Replies:
    0
    Views:
    1,012
  2. Replies:
    1
    Views:
    2,361
  3. titi

    if and and vs if and,and

    titi, Mar 9, 2007, in forum: VHDL
    Replies:
    4
    Views:
    591
    Mike Treseler
    Mar 11, 2007
  4. John Walsch
    Replies:
    0
    Views:
    201
    John Walsch
    Jul 9, 2004
  5. Mike

    Problem problem problem :( Need Help

    Mike, May 7, 2004, in forum: ASP General
    Replies:
    2
    Views:
    550
    Bullschmidt
    May 11, 2004
Loading...

Share This Page