For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > December 2004 > using pragma 'use locale'?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author using pragma 'use locale'?
Webmaster

2004-12-24, 8:55 am

Hi,

I'm russian perl programmer and I have a problem:

There is the part of Perl code:
# Remark: Cyrillic alphabet is used in the rest of code
# Remark: in the variable $query first letter of first word is uppercased, but in the
# array @keyw_array this letter is lowercased.
code:
$query = "Красивый дом на Реке"; @keyw_array = qw(красивый реке);

It is necessary to mark up in the $query all the words that array @keyw_array contains by bold style.
Then I write next instructions:
code:
$query =~ s/($_)/<strong>$1<\/strong>/i for @keyw_array; print $query; # prints Красивый дом на Реке

But on the server side the substitutions doesn't work properly (no change in the $query) although I specially used key 'i' in regex (s///i).
Locally using pragma 'use locale' resolves the problem, i.e.:
code:
use locale; $query =~ s/($_)/<strong>$1<\/strong>/i for @keyw_array; print $query; # prints <strong>Красивый</strong> дом на <strong>Реке</strong>

As you may see the substitutions have done properly.
But when I try this on the server side I have no substitutions again.

What is the matter?
Is somebody able to point me the right way?
Thanks.

AZtpa,





Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com