How to make this case insenstive

How to make this case insenstive

am 27.08.2007 15:44:41 von daniel

I am checking to see if the name is the same name as in $row[1] but
should be case insensitive.

my $line = DBI::neat_list(\@row, 70, ',');
if ($name ne $row[1])
do
error message

....
..

Is this possible?

Thank you!

Re: How to make this case insenstive

am 27.08.2007 15:50:49 von Tony Curtis

Daniel wrote:
> I am checking to see if the name is the same name as in $row[1] but
> should be case insensitive.
>
> my $line = DBI::neat_list(\@row, 70, ',');
> if ($name ne $row[1])
> do
> error message

That's easy, canonicalize both of them: e.g. lc() or uc(), q.v.

hth
t

Re: How to make this case insenstive

am 27.08.2007 15:58:11 von Sisyphus

"Daniel" wrote in message
news:1188222281.206237.216560@k79g2000hse.googlegroups.com.. .
>I am checking to see if the name is the same name as in $row[1] but
> should be case insensitive.
>
> my $line = DBI::neat_list(\@row, 70, ',');
> if ($name ne $row[1])
> do
> error message

my $line = DBI::neat_list(\@row, 70, ',');
if (lc($name) ne lc($row[1]))
do
error message

Cheers,
Rob

Re: How to make this case insenstive

am 27.08.2007 17:29:19 von it_says_BALLS_on_your forehead

On Aug 27, 9:44 am, Daniel wrote:
> I am checking to see if the name is the same name as in $row[1] but
> should be case insensitive.
>
> my $line = DBI::neat_list(\@row, 70, ',');
> if ($name ne $row[1])
> do
> error message
>
> ...
> .
>

an alternative to the lc() or uc() solution is to use a regex
(although this is probably less efficient).

if ( $name =~ m/$row[1]/i ) {
do {
blah

Re: How to make this case insenstive

am 27.08.2007 17:42:49 von jurgenex

Daniel wrote:
> I am checking to see if the name is the same name as in $row[1] but
> should be case insensitive.
>
> my $line = DBI::neat_list(\@row, 70, ',');
> if ($name ne $row[1])

> Is this possible?

Use normal forms, i.e. convert both to all lower or all upper case:
if (lc($name) ne lc($row[1])) {
If you loop through @row again and again it might be faster to store the
text in normal form.

Or you can use pattern matching with the /i option, but you need to be
careful to anchor the pattern at both ends and to block RE special
characters from being interpreted as such.

jue

Re: How to make this case insenstive

am 27.08.2007 17:46:19 von it_says_BALLS_on_your forehead

On Aug 27, 11:42 am, "Jürgen Exner" wrote:
> Daniel wrote:
> > I am checking to see if the name is the same name as in $row[1] but
> > should be case insensitive.
>
> > my $line =3D DBI::neat_list(\@row, 70, ',');
> > if ($name ne $row[1])
> > Is this possible?
>
> Use normal forms, i.e. convert both to all lower or all upper case:
> if (lc($name) ne lc($row[1])) {
> If you loop through @row again and again it might be faster to store the
> text in normal form.
>
> Or you can use pattern matching with the /i option, but you need to be
> careful to anchor the pattern at both ends and to block RE special
> characters from being interpreted as such.

gah! i was thinking about anchoring, but completely forgot to include
them in my post. thanks jue. i forgot about the escapes too, so double
thanks.

Re: How to make this case insenstive

am 28.08.2007 00:47:14 von rvtol+news

it_says_BALLS_on_your forehead schreef:
> Daniel:

>> I am checking to see if the name is the same name as in $row[1] but
>> should be case insensitive.
>>
>> my $line = DBI::neat_list(\@row, 70, ',');
>> if ($name ne $row[1])
>> do
>> error message
>
> an alternative to the lc() or uc() solution is to use a regex
> (although this is probably less efficient).
>
> if ( $name =~ m/$row[1]/i ) {
> do {
> blah

Missing: quotemeta.

--
Affijn, Ruud

"Gewoon is een tijger."

Re: How to make this case insenstive

am 28.08.2007 09:19:21 von Josef Moellers

it_says_BALLS_on_your forehead wrote:
> On Aug 27, 9:44 am, Daniel wrote:
>=20
>>I am checking to see if the name is the same name as in $row[1] but
>>should be case insensitive.
>>
>>my $line =3D DBI::neat_list(\@row, 70, ',');
>> if ($name ne $row[1])
>> do
>> error message
>>
>>...
>>.
>>
>=20
>=20
> an alternative to the lc() or uc() solution is to use a regex
> (although this is probably less efficient).
>=20
> if ( $name =3D~ m/$row[1]/i ) {
> do {
> blah

$name =3D "ThisIsALongFilename";
would match
$row[1] =3D "Filename";

You should anchor your pattern:

$name =3D~ m/^$row[1]$/i;

--=20
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html

Re: How to make this case insenstive

am 28.08.2007 16:57:19 von Uri Guttman

>>>>> "R" == Ruud writes:

R> it_says_BALLS_on_your forehead schreef:
>> Daniel:

>>> I am checking to see if the name is the same name as in $row[1] but
>>> should be case insensitive.
>>>
>>> my $line = DBI::neat_list(\@row, 70, ',');
>>> if ($name ne $row[1])
>>> do
>>> error message
>>
>> an alternative to the lc() or uc() solution is to use a regex
>> (although this is probably less efficient).
>>
>> if ( $name =~ m/$row[1]/i ) {
>> do {
>> blah

R> Missing: quotemeta.

also missing regex anchors which are needed since he did 'ne'.

uri

--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org

Re: How to make this case insenstive

am 30.08.2007 23:17:47 von rvtol+news

Uri Guttman schreef:
> Ruud:
>> it_says_BALLS_on_your forehead:
>>> Daniel:

>>>> I am checking to see if the name is the same name as in $row[1]
>>>> but should be case insensitive.
>>>>
>>>> my $line = DBI::neat_list(\@row, 70, ',');
>>>> if ($name ne $row[1])
>>>> do
>>>> error message
>>>
>>> an alternative to the lc() or uc() solution is to use a regex
>>> (although this is probably less efficient).
>>>
>>> if ( $name =~ m/$row[1]/i ) {
>>> do {
>>> blah
>>
>> Missing: quotemeta.
>
> also missing regex anchors which are needed since he did 'ne'.

ACK.

He did mention "the name in $var" though, which can be read as that $var
can contain more than just the name.

--
Affijn, Ruud

"Gewoon is een tijger."