good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: remove first and last character of stringby syphilis (Archbishop) |
on Oct 14, 2020 at 02:26 UTC ( [id://11122802]=note: print w/replies, xml ) | Need Help?? |
i've thought of using substr but i can't be sure that the number above in quotes will always be the same number of characters You can use substr() without knowing the number of characters. To remove the first character of $str: substr($str, 0, 1, '') To remove the last character of $str : substr($str, -1, 1, '') Or remove the last character of $str : substr($str, length($str) - 1, '') Or, just use chop() to remove the last character, as you've already noted. Cheers, Rob
In Section
Seekers of Perl Wisdom
|
|