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!
See Question&Answers more detail:osI 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!
See Question&Answers more detail:osWith substr()
:
substr($string, 0, -7);
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).
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.