您好,在调试器中我打印出以下变量$x
DB<8> x $x
0 ARRAY(0xdb09e20)
0 HASH(0xe18d450)
'OBJECT_ID' => 111026746749824
'TABLE_KEY' => '0-85296-384-X'
'TABLE_KEY_NAME' => 'VALUE'
1 HASH(0xe18d4e0)
'OBJECT_ID' => 1000000000108155
'TABLE_KEY' => '1598-8740'
'TABLE_KEY_NAME' => 'VALUE'
2 HASH(0xe18d530)
'OBJECT_ID' => 1000000000108156
'TABLE_KEY' => '89-7085-418-5'
'TABLE_KEY_NAME' => 'VALUE'
Run Code Online (Sandbox Code Playgroud)
我想循环遍历并访问每个OBJECT ID
我不知道该使用什么语法。
这是一个转储$x
[
{
OBJECT_ID => 111026746749824,
TABLE_KEY => "0-85296-384-X",
TABLE_KEY_NAME => "VALUE",
},
{
OBJECT_ID => 111026746749824,
TABLE_KEY => "0537-9987",
TABLE_KEY_NAME => "VALUE",
},
{
OBJECT_ID => 1000000000108155,
TABLE_KEY => "89-7085-386-3",
TABLE_KEY_NAME => "VALUE",
}, …Run Code Online (Sandbox Code Playgroud) 我想读取一个输入文件,然后删除一行,如果它匹配我的正则表达式.并保存文件没有该行.
我已经写了
open(my $fh, '<:encoding(UTF-8)', $original_file_path or die "Could not open file $original_file_path $!";
while (my $line = <$fh> ) {
chomp $line;
if ($line ~=/myregex/){
delete line from file
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢
我有两个相等长度的数组,一个包含键,另一个包含值.
如何将它们组合成一个哈希,我可以通过哈希{key}访问它并获取值.
我试过了
my %hash = map { $key[$_], $values[$_] } 0..$#key;
Run Code Online (Sandbox Code Playgroud)
但它有点保存在一个长列表中的所有内容,其中每个第二个值都是从调试器中可以看到的值.
DB<104> x %hash
0 'linking_parameter_1'
1 '$$SHIBBOLETH'
2 'service_type'
3 'getFullTxt'
4 'crossref_supported'
5 'Yes'
6 'parser'
7 'Bulk::BULK'
8 'internal_name'
9 'ELSEVIER_SD_EBOOK-COMPLETE_COLLECTION_1995-20065'
10 'object_lookup'
11 'yes'
12 'linking_level'
13 'BOOK'
14 'displayer'
15 'FT::NO_FILL_IN'
16 'parse_param'
17 ''
Run Code Online (Sandbox Code Playgroud)
当我输入
x %hash{parser}
Run Code Online (Sandbox Code Playgroud)
它不能评估.也许我只是不想以正确的方式访问它?
我的程序在target_services数组中有2个变量
DB<1> x @target_services
0 3400000000000012
1 3400000000000011
Run Code Online (Sandbox Code Playgroud)
这是它命中的代码
foreach my $i (@target_services){
my $vl = shift @values || "";
my $dp = shift @descriptions || "";
my $ts_id = shift @target_services;
my $lp = shift @lp_values;
if (get_lp($ts_id,$lp) eq 'YES'){
print "ts id $ts_id already has $lp LP. Aborting addition of this LP for this TS\n";
next;
}
my $temp_query = $sql3;
$temp_query =~ s/TS/$ts_id/;
$temp_query =~ s/LP/$lp/;
$temp_query =~ s/VL/$vl/;
$temp_query =~ s/DP/$dp/;
my $sth3 = get_sth($temp_query);
$count_lps+=$sth3->get_count(); …Run Code Online (Sandbox Code Playgroud) 我有一个名为$ title的字符串
Gardens and Anti-Gardens in Marie de France’s <i>Lais</i>
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误
"\x{2019}" does not map to iso-8859-1
Run Code Online (Sandbox Code Playgroud)
我尝试删除斜体标签,但它仍然给我错误,即
$title =~ s/<i>|<\/i>//g;
Run Code Online (Sandbox Code Playgroud)
谢谢