Re: BInding operator fails




Thank you both. I am trying to find out why "!~" operator fails. It is due to the whitespaces. but I am using "six" to ignore spaces.

Sorry guys. Below is the actual code. I made the changes that A.R. Ferreira suggested and it fails.

use strict;
use warnings;

my $rdns="cn=Exchange Sites,cn=Proxy Views,cn=JoinEngine Configuration,ou=Conf,o
u=InJoin,ou=applications,dc=marriott,dc=com";

my $result="cn=Exchange Sites";

if ($result !~ /\Q$rdns\E/six) {
print "\nresult: '$result'";
print "\nrdn: '$rdns'\n";
} else {
print "String is there\n";
}
OUTPUT is:
$ ./test.pl
result: 'cn=Exchange Sites'
rdn: 'cn=Exchange Sites,cn=Proxy Views,cn=JoinEngine Configuration,ou=Conf,ou=InJoin,ou=applications,dc=marriott,dc=com'

Tom your code works fine. But I was tring to understand why "!~" fails above.

use strict;
use warnings;

my $rdns="cn=Exchange Sites,cn=Proxy Views,cn=JoinEngine Configuration,ou=Conf,o
u=InJoin,ou=applications,dc=marriott,dc=com";

my $result="cn=Exchange Sites";

if ($result !~ /\Q$rdns\E/six) {
print "\nresult: '$result'";
print "\nrdn: '$rdns'\n";
} else {
print "String is there\n";
}
OUTPUT is:

String is there



-----Original Message-----
From: tom@xxxxxxxxxxxxxx
To: loveperl6@xxxxxxx
Cc: beginners@xxxxxxxx
Sent: Mon, 26 Feb 2007 12:29 PM
Subject: Re: BInding operator fails


On 2/26/07, loveperl6@xxxxxxx <loveperl6@xxxxxxx> wrote:

Hi. I have a problem with the below code. I have two strings, $rdns and $result1.
I want to make sure $result 1 is NOT part of $rdns. But the below fails...thus
instead of printing the else part of the if-else-loop. It print the main part. Does
anyone know what coudl cause this.

if ($result !~ /$rdns/ix) {

That's checking whether $rdns, as a pattern, does not match the string
in $result. (Was that supposed to be $result1?) But I think you're
asking for this, maybe:

if (index($rdns, $result) == -1) {
print "\$result isn't part of \$rdns.\n";
}

The index function is covered in perlfunc. Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

-- To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
http://learn.perl.org/

________________________________________________________________________
Check out the new AOL. Most comprehensive set of free safety and security tools, free access to millions of high-quality videos from across the web, free AOL Mail and more.


Relevant Pages