Well,
no one would get "trapped" in you if statements if you indented your code. That would help both you and the raving lunatic who will have to maintain your creation. ;)
Here, the warning is actually helpful. The thing to note here is that
substr doesn't work like
splice in that the position you higlight by LENGTH and OFFSET (see the
docs) isn't removed it is just identified. So with this substr, you tell perl go to the beginning of the string $links and look at one character. But you neither store that character anywhere or change it, which makes it void context. You don't change the string, and you don't store what you've found. So perl thinks somethings fishy.
If you want to remove that first character try:
substr($links, 0, 1) = undef;
or even
substr($links, 0, 1, undef);
HTH.