请教,如何在perl里匹配“【” or "】"

vio
请教,如何在perl里匹配“【” or "】"

例如匹配:
$str = "【关键词】";
$str =~ s/【//g; # not work

查了很多地方,没发现解决方法。
多谢!

cobrawgl
#!/usr/bin/perl

use strict;
use warnings;

use Encode;

my $src_str = '【关键词】';
my $src_p = '【';

my $test = decode('gb2312', $src_str);
my $pp = decode('gb2312', $src_p);

#print "ok" if $test =~ //Q$pp/E/;
$test =~ s//Q$pp/E//;
print encode('gb2312', $test);


_______________________

参考 [url]http://want2know.blog.hexun.com/3423584_d.html[/url]

vio
回复 #2 cobrawgl 的帖子

感谢!
非常感谢!

fdimim
汗~还能问下上面的
/Q   /E 是做什么用的?只是说消元符,搞不懂作用

socyno
回复 #4 fdimim 的帖子

避免$pp中有元字符导致匹配错误

Lonki
[quote]原帖由 [i]vio[/i] 于 2008-6-26 14:27 发表 [url=http://bbs.chinaunix.net/redirect.php?goto=findpost&pid=8668374&ptid=1171594][img]http://bbs.chinaunix.net/images/common/back.gif[/img][/url]
例如匹配:
$str = "【关键词】";
$str =~ s/【//g; # not work

查了很多地方,没发现解决方法。
多谢! [/quote]

试了下, Windows&Ubuntu下Perl5.8.8都没问题.
你源文件的编码?