Can't use string as a hash ref..?

你说的曾经没有我的故事 提交于 2019-12-05 23:36:25

The get_token() method returns an array where $token->[2] is a hash reference containing your href only if $token->[0] is an S (that is, a start tag). In this case, you are matching an end tag (where $token->[0] is an E). See the PerlDoc for details.

To fix, add a

next if $token->[0] ne 'S';

at the top of your loop.

$token->[2] is a string, not a hash reference.

Do a print $token->[2] and you'll see that it is a string containing </a>

apparently $token->[2] is resolving as a hash reference whose value is "</a>". Certainly not want you want!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!