我试图重用我们在内部使用的库函数,但是由于我的输入中有新的变体,所以事情并不正确,并且出现错误。Perl哈希键的合法值
我意识到问题在于它现在试图将一个时髦的句子指定为哈希键,例如下面的键列表,并且正如您所期望的那样,它并不喜欢它。有没有一种方法可以在对它进行哈希处理之前对其进行编码,以防止Perl出现任何堵塞现象?
Document: Multiple Attribute Equals (#root3 #form input[type=hidden], #root3 #form input[type=radio])
Document: Attribute selector using UTF8 (#root3 span[lang=ä¸æ–‡])
Document: Attribute Ends With (#root3 a[href $= 'org/'])
Document: Attribute Contains (#root3 a[href *= 'google'])
Document: Select options via [selected] (#root3 #select1 option[selected])
Document: Select options via [selected] (#root3 #select2 option[selected])
Document: Select options via [selected] (#root3 #select3 option[selected])
Document: Grouped Form Elements (#root3 input[name='foo[bar]'])
Document: :not() Existing attribute (#root3 #form select:not([multiple]))
Document: :not() Equals attribute (#root3 #form select:not([name=select1]))
任何字符串都是Perl中的合法哈希键,包括所发布内容的所有字符串和子字符串。此外,几乎任何标量值都可以转换为字符串并用作散列键,包括对列表,数组和大多数类实例的引用。所以不,我不一定会期望你使用哈希的函数不喜欢它。那么你试图避免的具体错误和噱头是什么?这些输入是什么给你带来麻烦? – mob
@mob:恩说。无可否认,使用字符串化引用作为散列键通常不是非常有用,但有一个_can_可以做到。实际上,你的评论中的“几乎”是不需要的:如果要求将标量_any_标量转换为字符串,则perl _will_将其转换为字符串,即使它可能会在执行时发出咳嗽和劈啪声并发出警告。 (好吧,我想可以使一个超载的标量的字符串转换例程“死亡”,但这只是简单的愚蠢。) –
也许你应该显示一些代码和错误。 – TLP