oops that's perfect. thanks Shlomi.
On 2018/7/27 星期五 PM 1:26, Shlomi Fish wrote:
Hi Lauren,
On Fri, 27 Jul 2018 11:28:42 +0800
"Lauren C." <lau...@miscnote.net> wrote:
greetings,
I was doing the log statistics stuff using perl.
There are chinese characters in log items.
I tried with regex to match them, but got no luck.
$ perl -mstrict -le 'my $char="汉语"; print "it is chinese" if $char =~
/\p{Han}+/'
$ perl -mstrict -mutf8 -le 'my $char="汉语"; print "it is chinese" if
$char =~ /\p{Han}+/'
both output nothing.
My terminal is UTF-8:
According to http://perldoc.perl.org/perlrun.html , you probably need -Mstrict
and -Mutf8 instead of the lowercase -m, so "sub import" will get called:
shlomif@telaviv1:~$ perl -Mstrict -Mutf8 -le 'my $char="汉语"; print "it is
chinese" if $char =~ /\p{Han}+/'
it is chinese
shlomif@telaviv1:~$
HTH,
Shlomi
$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
Can you help? thanks in advance.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/