in reply to howto strip the first char of a string?
New string:
$new = substr $old, 1
Modify old string:
substr($str, 0, 1) = ""
or
substr $str, 0, 1, ""
or
$str =~ s/^.//s
(notice the s modifier, which is needed if you want the code to also work if the first character is a \n. You may want to replace the ^ with \A for extra paranoia)
The other main point to consider is what you want to happen if the original string is empty. Error ? Warning ? Silence and just give the empty string as result ? All solutions are easily modified for whatever you want there.
|
|---|