Re: Perl programming question....
- From: "Ram" <ram0na@xxxxxxxxxxx>
- Date: 13 Oct 2006 00:57:59 -0700
Kevin Nathan wrote:
On Thu, 12 Oct 2006 11:06:12 GMT
Ram <Ram0na@xxxxxxxxxxx> wrote:
Kevin Nathan wrote:
print $A gt $B;
Before you do it, what do you *think* it will return, and why?
1, as ascii codes values for Caps are lower then lower case values
which I thought that's how it was done..
Give yourself a gold star! ;-) You're right, that's how it *is* done.
I was doing a CBT course at work yesterday and it turns out that the
example was wrong.
Yeah, that can be a real PITA when you're trying to learn something.
. . . searched google and the few books we have at work, and could
not find how string are compared, in C I believe it's one letter at a
time but in Perl ( I know now ) all the letter done as one word
alphabetically
I'm not sure I know what you mean by "one word alphabetically". IME, it
*is* comparing one letter at a time. For example, running this script:
#============================================
#!/usr/bin/perl
my @strings = qw( abc ABC zaa zba Azz Ayy Tom Wilkins xyz stu Yzz ZAA );
my $i;
while ( $i < scalar(@strings) )
{
print "$strings[$i] gt $strings[$i+1] = ",
$strings[$i] gt $strings[$i+1], "\n";
$i += 2;
}
#============================================
which yields:
abc gt ABC = 1
zaa gt zba =
Azz gt Ayy = 1
Tom gt Wilkins =
xyz gt stu = 1
Yzz gt ZAA =
Trying to see if "one word alphabetically" would make the last pair
true, since overall the ZAA is less than Yzz if you look at the entire
ASCII values, but it appears that the Z gt Y is enough to make it
false.
Or maybe I'm missing something . . . ;-)
That's the way I see it, Kev.
$A = Ram
$B = ram
$C = r
$D = R
sorted as I see it in Perl, testing ge:
ram
r
Ram
R
Ram
.
- References:
- Perl programming question....
- From: Ram
- Re: Perl programming question....
- From: Kevin Nathan
- Re: Perl programming question....
- From: Ram
- Re: Perl programming question....
- From: Kevin Nathan
- Perl programming question....
- Prev by Date: Re: The pictures I have linked here are of Shitsuse, a poor man's windows.
- Next by Date: Re: Hans Reiser (ReiserFS) Arrested On Suspicion of Murder
- Previous by thread: Re: Perl programming question....
- Next by thread: Re: Perl programming question....
- Index(es):