Worth reading, including the end where Jonathan
expands on his earlier post.
-Original Message-
From: Jonathan E. Paton [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 29, 2002 1:32 PM
To: Collins, Joe (EDSIBDR)
Subject: RE: Comparing strings
| > Don't know if this helps,
how much beginning does it take for one to officially
become a beginner? these double colons are looking
quite fancy...
crashdude®
--- Chris Zampese <[EMAIL PROTECTED]> wrote:
> me again :)
>
> Just realised that I did not give you an
> explanation of why this works...
>
> The expression
I was going to try:
if (uc($one) eq uc($two)){
etc.
But will this be okay with non-alphabetic characters?
"Jonathan E. Paton" <[EMAIL PROTECTED]> on 01/29/2002 11:42:52 AM
To: [EMAIL PROTECTED]
cc:
Subject: Re: Comparing strings
> Don't know if this
> Don't know if this helps, but the following code
>
> $one = "ExamPle";
> $two = "example";
>
> if ($one=~/$two/i) {
> print "true ";
> }
>
This is a bad idea for anything other than throwaway
scripts... it requires building a full regex everytime
(from $two). You *MUST* use quotemeta()
me again :)
Just realised that I did not give you an explanation of why this works...
The expression is a simple regex (see Perl Documentation). The =~ is sort
of the 'equal to' part, and the i at the end makes the comparison case
insensitive.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
dont know if this helps, but the following code
$one = "ExamPle";
$two = "example";
if ($one=~/$two/i)
{
print "true ";
}
print "false";
outputs:
true false
(ie evaluates the expression in the curly braces)
and if you change the top word to ExanPle (change the m to n)
then it only outputs:
[EMAIL PROTECTED] wrote:
> Hi
>
> I wish to do string comparisons where the case is ignored, for example:
>
> $one = "ExanPle";
> $two = ""example";
>
> if ($one eq $two){
> THIS RETURNS TRUE
if (lc($one) eq lc($two)) { #perldoc -f lc
HTH,
Sudarsan
>
>
> What do I add s
Hi
I wish to do string comparisons where the case is ignored, for example:
$one = "ExanPle";
$two = ""example";
if ($one eq $two){
THIS RETURNS TRUE
What do I add so that the comparison ignores the case?
Thanks in advance
eddie
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additi
chomp $character;
You need to get rid of the newline character at the end of every string
from
On Wed, 14 Nov 2001, samuel wrote:
> Hi there!
> i'm seeking for help on something which should b easy, but has
> turned into my personal hell.
> i'm trying to compare character (but i guess it appl
How about
chomp($character=);
?
At 11:13 AM 11/14/2001, samuel wrote:
>print"\nCharacter?:";
>$character= ;
Sliante,
Richard S. Crawford
http://www.mossroot.com
mailto:[EMAIL PROTECTED]
AIM: Buffalo2K ICQ: 11646404 Y!: rscrawford
"It is only with the heart that we see rightly;
Hi there!
i'm seeking for help on something which should b easy, but has
turned into my personal hell.
i'm trying to compare character (but i guess it applies the same to
strings) for my database entry markers, but i simpled the problem
out to this:
#Here starts my nightmare
print"\nCharacter
Kurt,
> if ($client ne $newclient and $method ne $newmethod){
> print "something\n";#I'll actually be
> printing this to my report once I get this worked out
> }
I think what you want is:
if (($client ne $newclient)&&($method ne $newmethod)) { ... }
This is c
The program I'm writing (my first in Perl) takes a log file and using a
regex pulls out all lines that contains certain words and writes them to a
file. Then I read in that file, seperate out the fields I want (IP address
and method), and want to eliminate the duplicates, and add a count to show
--- "Jos I. Boumans" <[EMAIL PROTECTED]> wrote:
> yeah, rub it in... i already corrected it... not sure *what* i was
> thinking... br4n3 fry...
>
> SORRY =)
lol -- not that I would criticize a better coder.
Just watching out for the nu-B's.
Notice *I* didn't even *attempt* to implement Inline:
yeah, rub it in... i already corrected it... not sure *what* i was
thinking... br4n3 fry...
SORRY =)
- Original Message -
From: "Paul" <[EMAIL PROTECTED]>
To: "Jos I. Boumans" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, June 22
--- "Jos I. Boumans" <[EMAIL PROTECTED]> wrote:
> stricly speaking 'foo' == 'bar' since both should yield 3.
er?
print int('foo'); # prints 0
__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/
to prove i sometimes write utter non sence too after a long week:
'foo' == 'bar' is true because they are both ZERO, not because their length
is both 3
'bar' == 'quux' too, etc
my humble apologies...
> i'm not sure i follow where you want to go...
> are you trying to compare ascii value? or len
lt b) { print "foo" }
perldoc perlop for more on this
hth,
Jos Boumans
- Original Message -
From: "Nick Transier" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, June 22, 2001 9:30 PM
Subject: comparing strings
> Does anyone know a way to m
At 02:30 PM 6/22/01 -0500, Nick Transier wrote:
>Does anyone know a way to make boolean comparisons between strings?
>For example, I want 'a' < 'b' to be true
'a' lt 'b'
>, but perl says 'a' == 'b' is true.
'a' eq 'b' is false
'a' == 'b' is true because each string is interpreted in a numeric
y, June 22, 2001 12:31
To: [EMAIL PROTECTED]
Subject: comparing strings
Does anyone know a way to make boolean comparisons between strings?
For example, I want 'a' < 'b' to be true, but perl says 'a' == 'b' is true.
Thanks,
-Nick
__
I think :
"a" cmp "b" ; # -1 ab
> -Original Message-
> From: Nick Transier [mailto:[EMAIL PROTECTED]]
> Sent: Friday, June 22, 2001 3:31 PM
> To: [EMAIL PROTECTED]
> Subject: comparing strings
>
>
> Does anyone know a way to make boolean c
--- Nick Transier <[EMAIL PROTECTED]> wrote:
> Does anyone know a way to make boolean comparisons between strings?
> For example, I want 'a' < 'b' to be true, but perl says 'a' == 'b' is
> true.
Use the string comparators. =o)
'a' lt 'b'
'a' == 'b' is true because they're both zero.
'a' eq 'b'
Does anyone know a way to make boolean comparisons between strings?
For example, I want 'a' < 'b' to be true, but perl says 'a' == 'b' is true.
Thanks,
-Nick
_
Get your FREE download of MSN Explorer at http://explorer.msn.com
23 matches
Mail list logo