如何在Perl中删除哈希值的最后七个字符? [英] How can I remove the last seven characters of a hash value in Perl?

查看:157
本文介绍了如何在Perl中删除哈希值的最后七个字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要截断字符串(存储在哈希中的字符串)的最后七个字符.在perl中最简单的方法是什么?提前非常感谢!

I need to cut off the last seven characters of a string (a string that is stored in a hash). What is the easiest way to do that in perl? Many thanks in advance!

推荐答案

使用 substr() :

substr($string, 0, -7);

我建议您在复制并将其粘贴到您的代码之前,先阅读substr()(我在上面链接到)上的Perldoc页面.它可以满足您的要求,但是substr()是非常有用且用途广泛的功能,我建议您了解可以使用它的所有功能(通过阅读文档).

I suggest you read the Perldoc page on substr() (which I linked to above) before just copying and pasting this into your code. It does what you asked, but substr() is a very useful and versatile function, and I suggest you understand everything you can use it for (by reading the documentation).

此外,将来,在这里问之前,请考虑对您的问题进行谷歌搜索(或者,对于Perl,在Perldoc上查询).您可以在诸如此类的东西上找到大量资源,而不必在这里提问.不说您的问题,但这很简单,我认为,如果您尝试过,就可以自己找到答案.

Also, in the future, please consider Googling your question (or, in the case of Perl, looking it up on Perldoc) before asking it here. You can find great resources on things like this without having to ask questions here. Not to put down your question, but it's pretty simple, and I think if you tried, you could find the answer on your own.

这篇关于如何在Perl中删除哈希值的最后七个字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆