我有我的字符串如下,我想删除第一个{没有任何东西只有第一个是字符串的开始。字符串在替换之前打印得很好,但在替换空字符串之后。Perl字符串替换?
use strict;
use warnings;
my $string = {"something":[{"some":"12","some":"something","data":"","data":"data2","age":"23"},{......},{.....}]}
# the string is valid as it is json from some array function.
print $string."\n"; #My string prints fine here
$string = s/\{//;
print "String after replacement".".$string." testing";
从技术上讲,在这种情况下'$ string'是一个散列引用,而不是一个字符串。 – redbmk 2013-03-19 22:07:41
这不是你的原始代码,因为这段代码不能编译。 '$ string'赋值是一个未加引号的json字符串,最后一个'print'语句包含5个引号。除了您遇到问题的确切代码之外,不要发布任何内容。 – TLP 2013-03-19 22:22:01