Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > eq and =? problem?

Reply
Thread Tools

eq and =? problem?

 
 
Geoff Cox
Guest
Posts: n/a
 
      03-20-2007
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);
}
 
Reply With Quote
 
 
 
 
Adrian Ulrich
Guest
Posts: n/a
 
      03-20-2007

> Any ideas please?


This works just fine for me.

How about providing the full script or a simple testcase?

 
Reply With Quote
 
 
 
 
Geoff Cox
Guest
Posts: n/a
 
      03-20-2007
On Tue, 20 Mar 2007 10:41:29 +0100, Adrian Ulrich
<(E-Mail Removed)> 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
 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      03-20-2007

[ 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
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
Geoff Cox
Guest
Posts: n/a
 
      03-20-2007
On Tue, 20 Mar 2007 05:55:00 -0500, Tad McClellan
<(E-Mail Removed)> 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
 
Reply With Quote
 
Adrian Ulrich
Guest
Posts: n/a
 
      03-20-2007
> 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";
}
 
Reply With Quote
 
Geoff Cox
Guest
Posts: n/a
 
      03-20-2007
On Tue, 20 Mar 2007 21:54:51 +0100, Adrian Ulrich
<(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
if and and vs if and,and titi VHDL 4 03-11-2007 05:23 AM



Advertisments